ACM/ICPC ZOJ1006-Do the Untwist 解题代码
2013-07-08 20:15
260 查看
#include <iostream> #include <string> #include <stdlib.h> using namespace std; int main() { string array[30][2]; string a,b; int t=0; while( cin >> a ) { if ( a == "0" ) { break; } else { cin >> b; } array[t][0] = a; array[t][1] = b; t++; } for ( int i = 0; i < t; i++ ) { const char *p = array[i][0].c_str(); int k = atoi(p); int len = array[i][1].size(); int *ciphercode = new int[len]; for ( int s = 0; s <len; s++ ) { if ( array[i][1][s] == '.') { ciphercode[s] = 27; } else if ( array[i][1][s] == '_') { ciphercode[s] = 0; } else { ciphercode[s] = array[i][1][s] - 96; } } int *plaincode = new int[len]; for ( int s = 0; s < len; s++ ) { int pt = ( k*s )%len; plaincode[pt] = (ciphercode[s] + s)%28; //cout <<pt <<" "<< plaincode[pt] << " "; } //cout << endl; char *plaintext = new char[len]; //cout << plaintext << endl; for ( int s = 0; s < len; s++ ) { if (plaincode[s] == 0 ) { plaintext[s] = '_'; } else if (plaincode[s] == 27 ) { plaintext[s] = '.'; } else { plaintext[s] = plaincode[s] + 96; } } //string resut(plaintext); for ( int m = 0; m < len; m++ ) { cout << plaintext[m]; } cout << endl; delete [] plaincode; delete [] plaintext; delete [] ciphercode; } return 0; }
相关文章推荐
- 【九度】抓取九度AC所有代码以及在CSDN的解题思路链接形成文件提交至github
- do not repeat yourself:使用反射配合mybais mapper,300行代码搞定逻辑相似对象增删查改
- ACM-1006-Do the Untwist
- asp.net如何加快页面加载(三)——后台代码之细节2(while,do..while,for,foreach)
- 解题报告之代码 pku 1789
- ZOJ1006-Do the Untwist
- 去掉代码中自动生成的TODO Auto-generated method stub
- 个人选拔赛第三场 解题代码
- hdoj 1129 Do the Untwist(数学公式+英文理解)
- ACM/ICPC ZOJ1003-Crashing Balloon 解题代码
- yii2:doajax(post)会报500错误 (个人项目代码奉上,希望对大家有帮助, 下面是执行一个删除操作)
- 1006 Do the Untwist
- Do the Untwist (1006)
- 最长上升连续子序列(解题代码)
- asp代码的一个do。。。wile循环代码
- 内核代码宏中 do{...}while(0) 的作用以及宏中#和##的作用及典型应用
- do_pj--下拉代码脚本的使用
- 【HDU1686】Oulipo 思路+解题报告+代码+KMP算法个人理解 【0.5%达成】
- hdu 1253 胜利大逃亡 (代码详解)解题报告
- HDU 4723 How Long Do You Have to Draw 解题报告