#include <bits/stdc++.h> #define int long long using namespace std; string s; bool prime(string xx) { if (xx[0] == '0') return false; int x = stoll(xx); if (x < 2) return false; for (int i = 2; i*i <= x; ++i) if (x%i == 0) return false; return true; } signed main() { cin >> s; for (int i = 1; i < s.size(); ++i) { if (prime(s.substr(0, i)) && prime(s.substr(i))) { cout<<"TAK\n"; return 0; } } 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 | #include <bits/stdc++.h> #define int long long using namespace std; string s; bool prime(string xx) { if (xx[0] == '0') return false; int x = stoll(xx); if (x < 2) return false; for (int i = 2; i*i <= x; ++i) if (x%i == 0) return false; return true; } signed main() { cin >> s; for (int i = 1; i < s.size(); ++i) { if (prime(s.substr(0, i)) && prime(s.substr(i))) { cout<<"TAK\n"; return 0; } } cout<<"NIE\n"; } |