| 比赛 | 
    NOIP2015普及组练习 | 
    评测结果 | 
    AAAAAAAAAA | 
    | 题目名称 | 
    Vigenère密码 | 
    最终得分 | 
    100 | 
    | 用户昵称 | 
    AOA | 
    运行时间 | 
    0.006 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    0.19 MiB  | 
    | 提交时间 | 
    2015-11-03 08:52:53 | 
显示代码纯文本
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<cctype>
#include<iostream>
#include<algorithm>
using namespace std;
const int kkk[26][26]={
    {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25},
    {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0},
    {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,1},
    {3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,1,2},
    {4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,1,2,3},
    {5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,1,2,3,4},
    {6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,1,2,3,4,5},
    {7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,1,2,3,4,5,6},
    {8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,1,2,3,4,5,6,7},
    {9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,1,2,3,4,5,6,7,8},
    {10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,1,2,3,4,5,6,7,8,9},
    {11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,1,2,3,4,5,6,7,8,9,10},
    {12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,1,2,3,4,5,6,7,8,9,10,11},
    {13,14,15,16,17,18,19,20,21,22,23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12},
    {14,15,16,17,18,19,20,21,22,23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13},
    {15,16,17,18,19,20,21,22,23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14},
    {16,17,18,19,20,21,22,23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
    {17,18,19,20,21,22,23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},
    {18,19,20,21,22,23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17},
    {19,20,21,22,23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18},
    {20,21,22,23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19},
    {21,22,23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
    {22,23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21},
    {23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22},
    {24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23},
    {25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}
};
string s,mi;
void init()
{
    freopen("vigenere.in","r",stdin);
   freopen("vigenere.out","w",stdout);
    
    string temp;
    cin>>s;temp=s;
    cin>>mi;
    while(s.length()<mi.length()) s+=temp;
    
}
char find(char x,char y)
{
    bool sign=false;
    if(y>='A' && y<='Z') sign=true;
    x=tolower(x);y=tolower(y);
    char ans;
    for(int i=0;i<26;i++)
        if(kkk[x-'a'][i]==y-'a') {ans=i+'a';break;}
    if(sign) ans=toupper(ans);
    return ans;
}
void work()
{
    for(int i=0;i<mi.length();i++)
        cout<<find(s[i],mi[i]);
}
int main()
{
    init();
    work();
    return 0;
}