#include <bits/stdc++.h> using namespace std; bool ok(int a){ return 'a' <= a && a <= 'z'; } int main(){ int c; using ll = long long; #define int long long ll base = 971; ll mod = 1e9+7; ll b = 1; ll h1 = 0; ll h2 = 0; c = getchar(); while(!ok(c))c = getchar(); do { h1 *= base; h1 += c; h2 += b*c; b *= base; h1 %= mod; h2 %= mod; b %= mod; c = getchar(); } while(ok(c)); if(h1 == h2){ cout << "TAK\n"; } else { cout <<"NIE\n"; } return 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 26 27 28 29 30 31 32 33 34 35 36 37 | #include <bits/stdc++.h> using namespace std; bool ok(int a){ return 'a' <= a && a <= 'z'; } int main(){ int c; using ll = long long; #define int long long ll base = 971; ll mod = 1e9+7; ll b = 1; ll h1 = 0; ll h2 = 0; c = getchar(); while(!ok(c))c = getchar(); do { h1 *= base; h1 += c; h2 += b*c; b *= base; h1 %= mod; h2 %= mod; b %= mod; c = getchar(); } while(ok(c)); if(h1 == h2){ cout << "TAK\n"; } else { cout <<"NIE\n"; } return 0; } |