#include <iostream> #include <cmath> using namespace std; bool isFirst(long long number) { if (number < 2) return false; for (long long i=2;i*i<=number;i++) { if (number%i==0) return false; } return true; } int main() { string n; cin >> n; for (int del=1;del<n.size();del++){ string left = n.substr(0,del); string right = n.substr(del ,n.size() - del); long long l = std::stoll(left); long long r = std::stoll(right); int lSize = log10(l) + 1; int rSize = log10(r) + 1; if (lSize != left.size() || rSize != right.size()) continue; if (isFirst(l) && isFirst(r)){ cout << "TAK" << endl; return 0; } } cout << "NIE"<< endl; }
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 | #include <iostream> #include <cmath> using namespace std; bool isFirst(long long number) { if (number < 2) return false; for (long long i=2;i*i<=number;i++) { if (number%i==0) return false; } return true; } int main() { string n; cin >> n; for (int del=1;del<n.size();del++){ string left = n.substr(0,del); string right = n.substr(del ,n.size() - del); long long l = std::stoll(left); long long r = std::stoll(right); int lSize = log10(l) + 1; int rSize = log10(r) + 1; if (lSize != left.size() || rSize != right.size()) continue; if (isFirst(l) && isFirst(r)){ cout << "TAK" << endl; return 0; } } cout << "NIE"<< endl; } |