#include <iostream>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
long long const lp=1004355043;
long long haszl=0, haszp=0, mp=1;
char c;
int l;
while(cin>>c)
{
if(c=='a')
l=0;
else if(c=='b')
l=1;
else if(c=='c')
l=2;
else if(c=='d')
l=3;
else if(c=='e')
l=4;
else if(c=='f')
l=5;
else if(c=='g')
l=6;
else if(c=='h')
l=7;
else if(c=='i')
l=8;
else if(c=='j')
l=9;
else if(c=='k')
l=10;
else if(c=='l')
l=11;
else if(c=='m')
l=12;
else if(c=='n')
l=13;
else if(c=='o')
l=14;
else if(c=='p')
l=15;
else if(c=='q')
l=16;
else if(c=='r')
l=17;
else if(c=='s')
l=18;
else if(c=='t')
l=19;
else if(c=='u')
l=20;
else if(c=='v')
l=21;
else if(c=='w')
l=22;
else if(c=='x')
l=23;
else if(c=='y')
l=24;
else if(c=='z')
l=25;
haszl=(haszl+(l*(mp)))%lp;
mp=(mp*26)%lp;
haszp=(haszp*26+l)%lp;
}
//cout<<haszl<<' '<<haszp<<endl;
if(haszl==haszp)
cout<<"TAK"<<'\n';
else
cout<<"NIE"<<'\n';
}
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; long long const lp=1004355043; long long haszl=0, haszp=0, mp=1; char c; int l; while(cin>>c) { if(c=='a') l=0; else if(c=='b') l=1; else if(c=='c') l=2; else if(c=='d') l=3; else if(c=='e') l=4; else if(c=='f') l=5; else if(c=='g') l=6; else if(c=='h') l=7; else if(c=='i') l=8; else if(c=='j') l=9; else if(c=='k') l=10; else if(c=='l') l=11; else if(c=='m') l=12; else if(c=='n') l=13; else if(c=='o') l=14; else if(c=='p') l=15; else if(c=='q') l=16; else if(c=='r') l=17; else if(c=='s') l=18; else if(c=='t') l=19; else if(c=='u') l=20; else if(c=='v') l=21; else if(c=='w') l=22; else if(c=='x') l=23; else if(c=='y') l=24; else if(c=='z') l=25; haszl=(haszl+(l*(mp)))%lp; mp=(mp*26)%lp; haszp=(haszp*26+l)%lp; } //cout<<haszl<<' '<<haszp<<endl; if(haszl==haszp) cout<<"TAK"<<'\n'; else cout<<"NIE"<<'\n'; } |
English