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 ...
随机推荐
- OpenRisc-42-or1200的ALU模块分析
引言 computer(计算机),顾名思义,就是用来compute(计算)的.计算机体系结构在上世纪五六十年代的时候,主要就是研究如何设计运算部件,就是想办法用最少的元器件(那时元器件很贵),最快的速 ...
- Linux系统的Cache工作原理和管理机制
Linux系统Cache 管理是 Linux 内核中一个很重要并且较难理解的组成部分.本文详细介绍了 Linux 内核中文件 Cache 管理的各个方面,希望能够帮助到你. 操作系统和文件 Cache ...
- wdlinux mysql innodb的安装
mysql innodb的安装 wget -c http://down.wdlinux.cn/in/mysql_innodb_ins.sh chmod 755 mysql_innodb_ins.sh ...
- Spring Data MongoDB example with Spring MVC 3.2
Spring Data MongoDB example with Spring MVC 3.2 Here is another example web application built with S ...
- [AngularJS + Webpack] Production Setup
Using Angular with webpack makes the production build a breeze. Simply alter your webpack configurat ...
- lenky的个人站点 ----LINUX 内核进程
http://www.lenky.info/archives/category/nix%E6%8A%80%E6%9C%AF/%E5%86%85%E6%A0%B8%E6%8A%80%E6%9C%AF
- myEclipse新建jsp,默认编码
修改地方在: myeclipse →fiter and editor →jsp
- 关于SqlServer修改数据库常用信息的方法
--系统表里存放各个数据库属性信息的表之一SELECT name AS [Logical Name], physical_name AS [DB File Path],type_desc AS [Fi ...
- ssh框架简单搭建
这里是个人对SSH框架搭建的一点心得,仅供新手,勿喷 首先,搞清楚分层, 视图层 --> 控制层 --> 业务层 --> DAO层--> 持久层 搭建的顺序是从后向前,搭建一 ...
- oracle中drop、delete和truncate的区别
oracle中drop.delete和truncate的区别 oracle中可以使用drop.delete和truncate三个命令来删除数据库中的表,网上有许多文章和教程专门讲解了它们之间的异同,我 ...