记录编号 |
133961 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2012]Vigenère密码 |
最终得分 |
100 |
用户昵称 |
Asm.Def |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.001 s |
提交时间 |
2014-10-28 23:04:42 |
内存使用 |
0.31 MiB |
显示代码纯文本
/*====================================================================================*/
/*==================================by Asm.Def========================================*/
/*====================================================================================*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <memory.h>
#include <vector>
#include <set>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <ctime>
#include <iterator>
#include <functional>
#include <cstdlib>
using namespace std;
#define forall(it,v) for(__typeof(v.begin()) it = v.begin();it < v.end();++it)
#define pb push_back
#define REP(i,j,k) for(i = j;i <= k;++i)
#define REPD(i,j,k) for(i = j;i >= k;--i)
typedef long long LL;
#if defined DEBUG
FILE *in = fopen("test", "r");
#define out stdout
#else
FILE *in = fopen("vigenere.in","r");
FILE *out = fopen("vigenere.out","w");
#endif
template <typename T>inline void getint(T &x){
char c = fgetc(in);
while(!isdigit(c))c = fgetc(in);
x = c - '0';
while(isdigit(c = fgetc(in)))x = x * 10 + c - '0';
}
/*===================================WORK============================================*/
const int maxn = 100 + 2;
int key[maxn], n = 0;
int main(){
char c = fgetc(in), tmp;
while(!isalpha(c))c = fgetc(in);
while(isalpha(c)){
key[n] = c - 'A';
if(key[n] > 25)key[n] -= 'a' - 'A';
++n;
c = fgetc(in);
}
int i = 0;
while(!isalpha(c))c = fgetc(in);
while(isalpha(c)){
if(c - 'A' > 25)tmp = 'a';
else tmp = 'A';
fputc((c - tmp + 26 - key[i]) % 26 + tmp, out);
i = (i + 1) % n;
c = fgetc(in);
}
//---------------------------------------------------------------------------------
#if defined DEBUG
cout << endl << (double)clock() / CLOCKS_PER_SEC <<endl;
#endif
return 0;
}
/*===================================================================================*/