0%

[題解]加密解密

a107. 加密解密

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
#include <bits/stdc++.h>
#define N 105
#define mod 1000000007
#define FOR(i,n) for(int i=0;i<n;i++)
#define ios ios::sync_with_stdio(0)
using namespace std;
string a = "abcdefghijklmnoprstuvwxyz";
string b = "EXAMPLBCDFGHIJKNORSTUVWYZ";

signed main(){
ios;
int n;string s;
cin>>n;cin.ignore();
getline(cin,s);
reverse(s.begin(),s.end());
string origin = b ,key = a;
if(s[0]>='a'&& s[0]<='z')swap(origin,key);

for(int i=0;i<n;i+=2){
int p1 = origin.find(s[i]),p2 = origin.find(s[i+1]);
cout<<key[5*(p1/5)+(p2%5)]<<key[5*(p2/5)+(p1%5)];
}
cout<<endl;
}