#include <iostream>
#include <string>
using namespace std;
int main()
{
int strwide;
cin >> strwide;
pair< char, char > rotor[][];
pair< char, char > rotor_instead[][];
string input;
int t = ; while( t < )
{
cin >> input;
if ( input.size() == strwide )
{
char start_1 = 'a';
char start_else = 'A';
if ( t == )
{
for ( int m = ; m < input.size(); m++ )
{
rotor[t][m].first = start_1;
rotor[t][m].second = input[m];
start_1 = start_1 + ;
}
}
else
{
for ( int m = ; m < input.size(); m++ )
{
rotor[t][m].first = start_else;
rotor[t][m].second = input[m];
start_else = start_else + ;
}
}
//rotor[t] = input;
t++;
}
} int crypto_number;
cin >> crypto_number;
//string *crypto = new string[crypto_number];
string crypto[];
t = ;
string input_crypto;
while( cin >> input_crypto && input_crypto != "" && t < crypto_number )
{
crypto[t] = input_crypto;
t++;
}
/*for ( int l = 0; l < t; l++ )
{
cout << crypto[l]<< endl;
}*/
//string *crypto_return = new string[crypto_number];
for ( int i = ; i < crypto_number; i++ )
{
for( int a = ; a < ; a++ )
{
for ( int b = ; b < strwide; b++ )
{
rotor_instead[a][b] = rotor[a][b];
}
}
//int second_rotor_count = 0;
//char *crypto_return = new char[crypto[i].size()];
char crypto_return[];
//cout << crypto[i].size() << endl;
for ( int j = ; j < crypto[i].size(); j++ )
{
for ( int r = ; r < strwide; r++ )
{
if ( rotor_instead[][r].second == crypto[i][j])
{
crypto_return[j] = rotor_instead[][r].first; for ( int k = ; k < strwide; k++ )
{
if ( rotor_instead[][k].second == crypto_return[j])
{
crypto_return[j] = rotor_instead[][k].first;
for ( int s = ; s < strwide; s++ )
{
if ( rotor_instead[][s].second == crypto_return[j] )
{
crypto_return[j] = rotor_instead[][s].first;
}
}
} }
} } for ( int d = ; d < strwide; d++ )
{
rotor_instead[][d].first += ;
rotor_instead[][d].second += ;
if (rotor_instead[][d].first == 'a'+ strwide )
{
rotor_instead[][d].first -= strwide;
}
if ( rotor_instead[][d].second == 'A'+strwide )
{
rotor_instead[][d].second -= strwide;
}
} if ( (j+)%strwide == )
{
//second_rotor_count++;
for ( int d = ; d < strwide; d++ )
{
rotor_instead[][d].first += ;
rotor_instead[][d].second += ;
if ( rotor_instead[][d].first == 'A'+strwide )
{
rotor_instead[][d].first -= strwide;
}
if ( rotor_instead[][d].second == 'A'+strwide )
{
rotor_instead[][d].second -= strwide;
}
}
} if ( (j + )%( strwide*strwide) == )
{
for ( int d = ; d < strwide; d++ )
{
rotor_instead[][d].first += ;
rotor_instead[][d].second += ;
if ( rotor_instead[][d].first == 'A'+strwide )
{
rotor_instead[][d].first -= strwide;
}
if ( rotor_instead[][d].second == 'A'+strwide )
{
rotor_instead[][d].second -= strwide;
}
}
} } /*for ( int a = 0; a < 3; a++ )
{
for ( int b = 0; b < strwide; b++ )
{
cout << rotor_instead[a][b].first <<" "<< rotor_instead[a][b].second << endl;
}
}*/
cout << "Enigma "<< i+ <<":"<< endl;
for ( int c = ; c < crypto[i].size(); c++ )
{
cout << crypto_return[c];
}
cout << endl;
if ( i != crypto_number - )
{
cout << endl;
} } return ;
}

ACM/ICPC ZOJ1009-Enigma 解题代码的更多相关文章

  1. ACM/ICPC ZOJ1003-Crashing Balloon 解题代码

    #include <iostream> using namespace std; int main() { int **array = new int *[100]; for ( int ...

  2. UVa 1225 - Digit Counting - ACM/ICPC Danang 2007 解题报告 - C语言

    1.题目大意 把前n$(n\le 10000)$个整数顺次写在一起:12345678910111213……计算0~9各出现了多少次. 2.思路 第一想法是打表,然而觉得稍微有点暴力.不过暂时没有想到更 ...

  3. UVa 1585 - Score - ACM/ICPC Seoul 2005 解题报告 - C语言

    1.题目大意 给出一个由O和X组成的字符串(长度为80以内),每个O的得分为目前连续出现的O的数量,X得分为0,统计得分. 2.思路 实在说不出了,这题没过脑AC的.直接贴代码吧.=_= 3.代码 # ...

  4. 【转】lonekight@xmu·ACM/ICPC 回忆录

    转自:http://hi.baidu.com/ordeder/item/2a342a7fe7cb9e336dc37c89 2009年09月06日 星期日 21:55 初识ACM最早听说ACM/ICPC ...

  5. hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...

  6. 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)

    摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...

  7. ACM/ICPC 之 BFS(离线)+康拓展开(TSH OJ-玩具(Toy))

    祝大家新年快乐,相信在新的一年里一定有我们自己的梦! 这是一个简化的魔板问题,只需输出步骤即可. 玩具(Toy) 描述 ZC神最擅长逻辑推理,一日,他给大家讲述起自己儿时的数字玩具. 该玩具酷似魔方, ...

  8. hduoj 4710 Balls Rearrangement 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4710 Balls Rearrangement Time Limit: 6000/3000 MS (Java/Ot ...

  9. 【转】ACM/ICPC生涯总结暨退役宣言—alpc55

    转自:http://hi.baidu.com/accplaystation/item/ca4c2ec565fa0b7fced4f811 ACM/ICPC生涯总结暨退役宣言—alpc55 前言 早就该写 ...

  10. hduoj 4708 Rotation Lock Puzzle 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/O ...

随机推荐

  1. VI编辑器的使用方法

    一.vi的工作模式vi有两种工作模式:  编辑模式:用来输入和编辑文件的模式,屏幕上会显示用户的键入,按键不是被解释为命令执行,而是作为文本写到用户的文件中.  指令模式:用来编辑.存盘和退出文件的模 ...

  2. POJ1456 Supermarket 贪心

    贪心策略:一定先卖价值最大的,然后考虑卖当前的物品,卖的日期越靠后,越优,可以为以后的物品提供机会 #include <stdio.h> #include <string.h> ...

  3. 【HTML】Intermediate7:Sectioning

    1.</article> 2.</section> can use h1 elements at the start of each section,which would b ...

  4. POJ1365 - Prime Land(质因数分解)

    题目大意 给定一个数的质因子表达式,要求你计算机它的值,并减一,再对这个值进行质因数分解,输出表达式 题解 预处理一下,线性筛法筛下素数,然后求出值来之后再用筛选出的素数去分解....其实主要就是字符 ...

  5. codeforces 432D Prefixes and Suffixes

    由于包含了前缀与后缀,很容易想到用KMP去算前缀与后缀的公共缀.另外要计算某个后缀在整个串中出现的次数,由于后缀自动机是比较容易求的,然后就直接上后缀自动机了.先分别用KMP算法与后缀自动机跑一遍,然 ...

  6. 北京Uber优步司机奖励政策(2月6日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  7. BZOJ 3280: 小R的烦恼 & BZOJ 1221: [HNOI2001] 软件开发

    3280: 小R的烦恼 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 399  Solved: 200[Submit][Status][Discuss ...

  8. 【腾讯Bugly干货分享】手游热更新方案xLua开源:Unity3D下Lua编程解决方案

    本文来自于腾讯Bugly公众号(weixinBugly),未经作者同意,请勿转载,原文地址:http://mp.weixin.qq.com/s/2bY7A6ihK9IMcA0bOFyB-Q 导语 xL ...

  9. IOS开发UIImage中stretchableImageWithLeftCapWidth方法的解释

    - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCap ...

  10. JAVA Web 之 struts2文件上传下载演示(二)(转)

    JAVA Web 之 struts2文件上传下载演示(二) 一.文件上传演示 详细查看本人的另一篇博客 http://titanseason.iteye.com/blog/1489397 二.文件下载 ...