NOIP 2012 Vigenère 密码

//(water problem)
#include<bits/stdc++.h>
//#pragma GCC optimize (3)
using namespace std;
int main()
{
	string s1,s2;
	getline(cin,s1);getline(cin,s2);
	int l1=s1.size(),l2=s2.size();
	for(register int i=0;i<l2;i++){
		char ch=s2[i];
		s2[i]-=((s1[i%l1]>='a')?(s1[i%l1]-'a'):s1[i%l1]-'A');
		if((ch>='a' && s2[i]<'a') || (ch>='A' && s2[i]<'A')) 
			s2[i]+=('z'-'a'+1);
	}
	cout<<s2;
    return 0;
}
posted @ 2022-09-18 13:17  Euouae  阅读(17)  评论(1编辑  收藏  举报