记录编号 |
200109 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2012]Vigenère密码 |
最终得分 |
100 |
用户昵称 |
翯翯龘 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.005 s |
提交时间 |
2015-10-27 22:00:36 |
内存使用 |
0.32 MiB |
显示代码纯文本
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <algorithm>
- using namespace std;
-
- const int maxn = 2000;
- char S[maxn],T[maxn];
-
- int calc(char c)
- {
- return (int(c)-65-(c>=97?32:0));
- }
-
- int main()
- {
- freopen("vigenere.in","r",stdin);
- freopen("vigenere.out","w",stdout);
- scanf("%s",S);
- scanf("%s",T);
- for (int i = 0 ; T[i]!='\0'; ++i)
- {
- for (int j = 0 ; j < 26; ++j)
- {
- if ((j+calc(S[i%strlen(S)]))%26 == calc(T[i]))
- printf("%c",j+65+(T[i]>=97?32:0));
- }
- }
- return 0;
- }