ACM/ICPC ZOJ1009-Enigma 解题代码
#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 解题代码的更多相关文章
- ACM/ICPC ZOJ1003-Crashing Balloon 解题代码
#include <iostream> using namespace std; int main() { int **array = new int *[100]; for ( int ...
- UVa 1225 - Digit Counting - ACM/ICPC Danang 2007 解题报告 - C语言
1.题目大意 把前n$(n\le 10000)$个整数顺次写在一起:12345678910111213……计算0~9各出现了多少次. 2.思路 第一想法是打表,然而觉得稍微有点暴力.不过暂时没有想到更 ...
- UVa 1585 - Score - ACM/ICPC Seoul 2005 解题报告 - C语言
1.题目大意 给出一个由O和X组成的字符串(长度为80以内),每个O的得分为目前连续出现的O的数量,X得分为0,统计得分. 2.思路 实在说不出了,这题没过脑AC的.直接贴代码吧.=_= 3.代码 # ...
- 【转】lonekight@xmu·ACM/ICPC 回忆录
转自:http://hi.baidu.com/ordeder/item/2a342a7fe7cb9e336dc37c89 2009年09月06日 星期日 21:55 初识ACM最早听说ACM/ICPC ...
- 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 ...
- 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)
摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...
- ACM/ICPC 之 BFS(离线)+康拓展开(TSH OJ-玩具(Toy))
祝大家新年快乐,相信在新的一年里一定有我们自己的梦! 这是一个简化的魔板问题,只需输出步骤即可. 玩具(Toy) 描述 ZC神最擅长逻辑推理,一日,他给大家讲述起自己儿时的数字玩具. 该玩具酷似魔方, ...
- 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 ...
- 【转】ACM/ICPC生涯总结暨退役宣言—alpc55
转自:http://hi.baidu.com/accplaystation/item/ca4c2ec565fa0b7fced4f811 ACM/ICPC生涯总结暨退役宣言—alpc55 前言 早就该写 ...
- 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 ...
随机推荐
- 洛谷P1220 关路灯
洛谷1220 关路灯 题目描述 某一村庄在一条路线上安装了n盏路灯,每盏灯的功率有大有小(即同一段时间内消耗的电量有多有少).老张就住在这条路中间某一路灯旁,他有一项工作就是每天早上天亮时一盏一盏地关 ...
- apple公司的潮起潮落——浪潮之巅
今天代码写不下去的时候,躺在床上看了一下浪潮之巅.翻了一下书目,选了apple公司那一篇. 其实apple公司的事情我已经听过不止一次了,但是每次都是间间断断地听说,都没有系统地了解它到底是经历了怎么 ...
- [Locked] Unique Word Abbreviation
Unique Word Abbreviation An abbreviation of a word follows the form <first letter><number&g ...
- POJ2752 - Seek the Name, Seek the Fame(KMP)
题目大意 给定一个字符串S,求出所有既是S的前缀又是S的后缀的子串长度 题解 从末尾位置倒推,经过的失配函数值就是题目要求求的 代码: #include <iostream> #inclu ...
- 小波变换和motion信号处理(一)(转)
写的太好,不得不转:http://www.kunli.info/2011/02/15/fourier-wavelet-motion-signal-1/ 这是<小波变换和motion信号处理> ...
- 【转】Vim 常用命令总结
使用 Vim 的时间不长,但如今已经离不开熟悉的 Vim 编辑模式了. Vim 的学习曲线是非常陡的,一开始学习的时候,面对很多的操作命令要去记住,常常望而却步. 其实,只要记住一些常用的命令,加之在 ...
- weblogic目录结构
安装WEBLOGIC SERVER weblogic server 的目录结构 weblogic server的classpath变量 weblogic server使用命令行 通过管理控制台执行核心 ...
- 利用dom4j读取xml文件
对于xml文件的读取,其实有很多方法,例如:SAX实现方法,DOM4J实现方法 ,DOM 实现方法,JDOM实现方法 等等. 下面,我就说下dom4j的读取方法: 1.首先,肯定要引入第三方jar包. ...
- Unix/Linux环境C编程新手教程(12) openSUSECCPP以及Linux内核驱动开发环境搭建
1. openSUSE是一款优秀的linux. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaXRjYXN0Y3Bw/font/5a6L5L2T/font ...
- [Webpack 2] Ensure all source files are included in test coverage reports with Webpack
If you’re only instrumenting the files in your project that are under test then your code coverage r ...