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 ...
随机推荐
- iScroll使用
新公司比较喜欢用iScroll,而我对此一无所知,特此调研iScroll用法,写在这里方便查看 IScroll是移动页面上被使用的一款仿系统滚动插件. myScroll = new IScroll(& ...
- android的生命周期
1.运行状态:当一个活动处于栈的顶部时,这时活动就处于活动状态,系统是不愿意回收处于活动状态的,会影响用户体验. 2.暂停状态:当一个活动不再处于栈的顶部时,但仍然可见时,这时就是暂停状态了.处于暂停 ...
- jqGrid在IE中使用iframe嵌套,页码条不显示问题
在网页顶部加: 红色部分必须是:XHTML1.0
- IOS-tableViewCell重用机制
IOS-tableViewCell重用机制 首先介绍tableViewCell原生cell的使用和重用机制 使用dequeueReusableCellWithIdentifier方法,这个方法会从缓存 ...
- 从高德 SDK 学习 Android 动态加载资源
前不久跑去折腾高德 SDK 中的 HUD 功能,相信用过该功能的用户都知道 HUD 界面上的导航转向图标是动态变化的.从高德官方导航 API 文档中 AMapNaviGuide 类的描述可知,导航转向 ...
- 【Android】数据的应用-使用sharedpreferences存储数据
Android应用开发SharedPreferences存储数据的使用方法 SharedPreferences是Android中最容易理解的数据存储技术,实际上SharedPreferences处理的 ...
- mailsend - Send mail via SMTP protocol from command line
Introduction mailsend is a simple command line program to send mail via SMTP protocol. I used to sen ...
- SQL Server 2008 安装指南
一.安装需求: 1.硬件需求条件 硬件 需求 处理器 最低:1.4 GHz(x64处理器)注意:Windows Server 2008 for Itanium-Based Systems 版本需要In ...
- PRD产品需求文档概要
PRD概念 PRM就是Product Requirements Document的简称,也就是产品需求模型.一般来说一个产品会伴随有市场需求文档(Market Requirements Documen ...
- linux下面安装和配置nginx
下载nginx-1.0.2.tar.gz wget nginx-1.0.2.tar.gz 解压 nginx-1.0.2.tar.gz tar -xzvf nginx-1.0.2.tar.gz 配置安装 ...