ZOJ 1006 Do the Untwist
2017-03-15 19:14
330 查看
#include <iostream> #include <string> #include <vector> #include <stack> #include <map> #include <memory.h> #include <string.h> #include <stdio.h> using namespace std; int main() { int key, n; char plaintext[80], ciphertext[80]; int plaincode[80], ciphercode[80]; map<char, int> MapA; map<int, char> MapB; for (char c = 'a'; c <= 'z'; c++) { MapA[c] = c - 'a' + 1; } MapA['_'] = 0; MapA['.'] = 27; for (int i = 1; i < 27; i++) { MapB[i] = 'a' + i - 1; } MapB[0] = '_'; MapB[27] = '.'; //freopen("d:\\input.txt", "r", stdin); while (cin >> key) { if (key == 0) { break; } cin >> ciphertext; n = strlen(ciphertext); for (int i = 0; i < n; i++) { ciphercode[i] = MapA[ciphertext[i]]; } for (int i = 0; i < n; i++) { plaincode[key*i%n] = (ciphercode[i] + i) % 28; } for (int i = 0; i < n; i++) { plaintext[i] = MapB[plaincode[i]]; } plaintext = 0; cout << plaintext << endl; } return 0; }
相关文章推荐
- zoj1006-Do the Untwist
- zoj&nbsp;1006&nbsp;Do&nbsp;the&nbsp;Untwist
- ZOJ 1006 Do the Untwist
- zoj 1006 Do the Untwist
- ZOJ 1006 Do the Untwist
- Zoj 1006 Do the Untwist
- zoj 1006 Do the Untwist
- zoj 1006 Do the Untwist
- zoj 1006 Do the Untwist
- ZOJ Problem Set - 1006 Do the Untwist
- DotheUntwist_1006
- 1006.Do the Untwist
- Do the Untwist
- ZOJ1006 untwist_Show Problem
- ZOJ1006 Do the Untwist
- TZU2014年省赛个人热身赛1 1187:Do the Untwist
- 浙大ZOJ 1006 Do the Untwist问题解决及其他人的解决方法
- Do the Untwist
- Do the Untwist
- (ZJU-2006复试)-ZOJ-1006-Do the Untwist