The Imitation Game

《The Imitation Game》是一部非常好的电影,讲述了人工智能之父——阿兰图灵的传奇一生。
重点讲述了他通过破译德国的通讯密码缩短了二战的持续时间,因而拯救了无数生命的伟大事迹。
强烈推荐大家去看一看,这可是豆瓣评分8.6的好片啊!
另外,《The Imitation Game》也是当年图灵发表的关于他对人工智能看法的论文。链接在此
德国当时的加密方式叫Enigma,具体是怎样的加密机制呢?图灵面临了怎样的挑战呢?
POJ 1449给了我们一次亲身体验破解Enigma的机会。
代码如下:
#include <cstdio>
#include <cstring>
using namespace std; #define D(x) int f[][];
int g[][];
int state[];
int cipher[];
int plain[];
int len;
int *mark[];
int mark_num;
bool ok;
int power[] = {, , * , * * }; int get_next(int a[])
{
char st[];
scanf("%s", st);
for (int i = ; st[i]; i++)
{
if (st[i] == '?')
{
a[i] = -;
mark[mark_num++] = &a[i];
continue;
}
a[i] = st[i] - 'a';
}
return strlen(st);
} void input()
{
mark_num = ;
for (int i = ; i < ; i++)
{
get_next(f[i]);
}
get_next(state);
len = get_next(plain);
get_next(cipher);
} void output()
{
for (int i = ; i < len; i++)
{
putchar(plain[i] + 'a');
}
puts("");
} int encrypt(int a, int pos)
{
int temp = f[][a];
int cur_state[];
int delta[]; for (int i = ; i < ; i++)
{
cur_state[i] = state[i] + pos / power[i];
cur_state[i] = (cur_state[i] + ) % ;
}
delta[] = cur_state[];
for (int i = ; i < ; i++)
{
delta[i] = (cur_state[i] - cur_state[i - ] + ) % ;
} for (int i = ; i < ; i++)
{
temp = f[i][(temp + delta[i] + ) % ];
} for (int i = ; i >= ; i--)
{
temp = g[i][(temp - delta[i + ] + ) % ];
} temp = g[][(temp - delta[] + ) % ];
return temp;
} bool check()
{
for (int i = ; i < ; i++)
{
for (int j = ; j < ; j++)
{
g[i][f[i][j]] = j;
}
} for (int i = ; i < len; i++)
{
if (encrypt(plain[i], i) != cipher[i])
{
return false;
}
}
return true;
} void dfs(int step)
{
if (ok)
{
return;
}
if (step == mark_num)
{
if (check())
{
ok = true;
output();
}
return;
}
for (int i = ; i < ; i++)
{
*mark[step] = i;
dfs(step + );
}
} void test(char a, int b)
{
check();
printf("%c %c\n", a, encrypt(a - 'a', b) + 'a');
} int main()
{
int t;
scanf("%d", &t);
for (int i = ; i <= t; i++)
{
printf("Scenario #%d:\n", i);
input();
ok = false;
dfs();
D(test('a', ));
puts("");
}
return ;
}
The Imitation Game的更多相关文章
- 深度学习课程笔记(七):模仿学习(imitation learning)
深度学习课程笔记(七):模仿学习(imitation learning) 2017.12.10 本文所涉及到的 模仿学习,则是从给定的展示中进行学习.机器在这个过程中,也和环境进行交互,但是,并没有显 ...
- #英文#品读中国城市个性——最好的和最坏的&当东方遇到西方
冒险家的乐园 a playground of risk 实现发财梦 realize one's dreams of wealth 道德沦丧,堕落 moral deprivation 租界 foreig ...
- Unix及类Unix系统文本编辑器的介绍
概述 Vim是一个类似于Vi的著名的功能强大.高度可定制的文本编辑器,在Vi的基础上改进和增加了很多特性.VIM是纯粹的自由软件. Vim普遍被推崇为类Vi编辑器中最好的一个,事实上真正的劲敌来自Em ...
- iOS开发之开源项目链接
1. Coding iOS 客户端 Coding官方客户端. 笔者强烈推荐的值得学习的完整APP.GitHub - Coding/Coding-iOS: Coding iOS 客户端源代码 2. OS ...
- AssetBundle loading failed because.....已解决
http://blog.csdn.net/ldghd/article/details/9632455 ***************************** 一 ******* ...
- 【Python + Selenium】Mock Testing 是啥?一个so上的高票答案。
There are many kinds of testing which really made me confused. To be honest, I've never heard of som ...
- 深度|OpenAI 首批研究成果聚焦无监督学习,生成模型如何高效的理解世界(附论文)
本文经机器之心(微信公众号:almosthuman2014)授权转载,禁止二次转载,原文. 选自 Open AI 作者:ANDREJ KARPATHY, PIETER ABBEEL, GREG BRO ...
- vim深入研究
About VIM--Unix及类Unix系统文本编辑器 Vim是一个类似于Vi的著名的功能强大.高度可定制的文本编辑器,在Vi的基础上改进和增加了很多特性.VIM是纯粹的自由软件. Vim普遍被推崇 ...
- GitHub 上有哪些完整的 iOS-App 源码值得参考?
1. Coding iOS 客户端 Coding官方客户端. 笔者强烈推荐的值得学习的完整APP.GitHub - Coding/Coding-iOS: Coding iOS 客户端源代码 2. OS ...
随机推荐
- cookie, localStorage, sessionStorage区别
cookie 有过期时间,默认是关闭浏览器后失效,4K,兼容ie6,不可跨域,子域名会继承父域名的cookielocalStorage 永不过期,除非手动删除,5M,兼容IE8,不可跨域,子域名不能继 ...
- Hibernate 查询MatchMode的四种模式
Hibernate 查询MatchMode的四种模式 MatchMode.START:字符串在最前面的位置.相当于"like 'key%'" MatchMode.END:字符串在最 ...
- zend stuido 12.5的插件安装和xdebug调试器的配置和和配置注意
参考: zend stuido 12.5的插件安装 zend 12.5 安装插件是按类别进行分类了的, 而且是在欢迎 界面就可以直接安装, 安装后,要重启zend才能生效 版式设计的一个基本点就是: ...
- firstchild.data与childNodes[0].nodeValue意思(转)
x.firstchild.data:获取元素第一个子节点的数据: x.childNodes[0]::获取元素第一个子节点; x.childNodes[0].nodeValue.:也是获取元素第一个子节 ...
- html 图像映射
个人先做而一个例子 <body> <img src="图像映射/enterdesk.com-D69055E2B422567CB273963EA05FF7D4.jpg&quo ...
- JSP中根据不同的条件显示不一样的格式
在做项目中遇到这样的场景: 当查询到记录时,需要将记录的字段作为下拉列表,让用户选择使用,即显示的是下拉列表. 当没有查询到记录时,则让用户手工填写该值,即显示的是文本框. 前段jsp使用if标签如下 ...
- 8-IO总结
3. 4. 5.
- JQuery在asp.net中三种ajax传值
1)通过webservice,注意去掉注释[System.Web.Script.Services.ScriptService]这行前的注释 2)通过aspx.cs文件中的静态方法 3)通过aspx文件 ...
- windows 下wamp环境2 配置之mysql的安装
安装配置mysql 5.7 打开mysql官网: https://www.mysql.com/ 点击downloads,然后选择commuity 选择MySQL Community Server选择对 ...
- All Kind Of Conference(随时更新...)
收集一些前端开发的各种会议,里面有视频或者PPT,随时查看都还是很有收获的.还有要向这些演讲的前辈看齐- AC 2015:http://ac.alloyteam.com/2015/ AC 2016:h ...