iscc2016-basic-find-to-me
额 第一题就暴力搜索了
已知仿射加密变换为c=(11m+8)mod26,试对密文sjoyuxzr解密
#include <stdio.h> int main(void)
{
int m,c;
while(scanf("%c",&m))
{
c = (11 * (m -97)+ 8)%26;
printf("%c",c+97);
}
return 0;
}
看了大神的代码 有所醒悟
c= Ek(m)=(k1m+k2) mod n {
c-k2 = k1 *m mod n 令k3*k1 mod n =1 得(c - k2) * k3 = m mod n m = (c - k2) * k3
} m=Dk(c)=k3(c- k2) mod n(其中(k3 ×k1)mod26 = 1)
def extendedGCD1(a, b):
# a*xi + b*yi = ri
if b == 0:
return (1, 0, a)
(x, y, r) = extendedGCD1(b, a%b)
"""
gcd(a, b) = a*xi + b*yi
gcd(b, a % b) = b*xi+1 + (a - [a/b]*b)*yi+1
gcd(a, b) = gcd(b, a % b) => a*xi + b*yi = a*yi+1 + b*(xi+1 - [a/b]*yi+1)
xi = yi+1
yi = xi+1 - [a/b]*yi+1
"""
tmp = x
x = y
y = tmp - (a/b) * y
return (x, y, r)
iscc2016-basic-find-to-me的更多相关文章
- Atitit HTTP 认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结
Atitit HTTP认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结 1.1. 最广泛使用的是基本验证 ( ...
- Basic Tutorials of Redis(9) -First Edition RedisHelper
After learning the basic opreation of Redis,we should take some time to summarize the usage. And I w ...
- Basic Tutorials of Redis(8) -Transaction
Data play an important part in our project,how can we ensure correctness of the data and prevent the ...
- Basic Tutorials of Redis(7) -Publish and Subscribe
This post is mainly about the publishment and subscription in Redis.I think you may subscribe some o ...
- Basic Tutorials of Redis(6) - List
Redis's List is different from C#'s List,but similar with C#'s LinkedList.Sometimes I confuse with t ...
- Basic Tutorials of Redis(5) - Sorted Set
The last post is mainly about the unsorted set,in this post I will show you the sorted set playing a ...
- Basic Tutorials of Redis(4) -Set
This post will introduce you to some usages of Set in Redis.The Set is a unordered set,it means that ...
- Basic Tutorials of Redis(3) -Hash
When you first saw the name of Hash,what do you think?HashSet,HashTable or other data structs of C#? ...
- Basic Tutorials of Redis(2) - String
This post is mainly about how to use the commands to handle the Strings of Redis.And I will show you ...
- Basic Tutorials of Redis(1) - Install And Configure Redis
Nowaday, Redis became more and more popular , many projects use it in the cache module and the store ...
随机推荐
- matches()方法
java.lang包中的String类和java.util.regex包中的Pattern,Matcher类中都有matches()方法,都与正则表达式有关.下面我分别举例:(字符串:"ab ...
- 用python正则表达式提取字符串
在日常工作中经常遇见在文本中提取特定位置字符串的需求.python的正则性能好,很适合做这类字符串的提取,这里讲一下提取的技巧,正则表达式的基础知识就不说了,有兴趣的可以看re的教程. 提取一般分两种 ...
- bzoj2822: [AHOI2012]树屋阶梯
咦,这里有好多东西https://en.wikipedia.org/wiki/Catalan_number 每个矩形最多贡献一个拐角 枚举左上角的点和那个拐角是一个矩形 #include<cst ...
- SQL server 创建表,索引,主键,外键
if object_id('student', 'U') is not null drop table student go create table student( sno varchar(20) ...
- 【JAVA - 基础】之数据加密和解密
1.Base64工具类(可逆): import java.util.HashMap; import java.util.Map; /** * Base64加解密算法 * </p> * Ba ...
- docker 实战---部署tomcat\weblogic集群 (二)
安装tomcat镜像 准备好须要的jdk tomcat等软件放到home文件夹以下 启动一个虚拟机 docker run -t -i -v /home:/opt/data --name mk_tom ...
- HDU 3065 AC自动机 裸题
中文题题意不再赘述 注意 失配数组 f 初始化一步到位 #include <stdio.h> #include <string.h> #include <queue&g ...
- [TypeScript] Understanding Generics with RxJS
Libraries such as RxJS use generics heavily in their definition files to describe how types flow thr ...
- auth tips
https://scotch.io/tutorials/easy-node-authentication-setup-and-local https://scotch.io/tutorials/upg ...
- 聊一聊Android 6.0的运行时权限
Android 6.0,代号棉花糖,自发布伊始,其主要的特征运行时权限就很受关注.因为这一特征不仅改善了用户对于应用的使用体验,还使得应用开发者在实践开发中需要做出改变. 没有深入了解运行时权限的开发 ...