#include<iostream> using namespace std; int main(){ int n; cin >> n; int counter = 0, sum = 0, exp = 1; char z; while(cin >> z){ if(counter == n/2 && n%2 == 1){counter+=1; continue;} sum = (sum + (exp * (z - 96))) % 28; exp = (exp * 27) % 28; counter += 1; } if(sum == 0){ 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 | #include<iostream> using namespace std; int main(){ int n; cin >> n; int counter = 0, sum = 0, exp = 1; char z; while(cin >> z){ if(counter == n/2 && n%2 == 1){counter+=1; continue;} sum = (sum + (exp * (z - 96))) % 28; exp = (exp * 27) % 28; counter += 1; } if(sum == 0){ cout << "TAK\n"; } else { cout << "NIE\n"; } } |