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