#include <iostream> #include <stdio.h> #include <string> #include <math.h> using namespace std; #define ull unsigned long long bool isPrime(ull n) { ull s = sqrt(n); for (int i = 2; i < s; ++i) if (n % i == 0) return false; return true; } void main3(ull n) { ull d = 10; ull x, y; while (n > d) { x = n / d; y = n % d; if (std::to_string(n).length() == std::to_string(x).length() + std::to_string(y).length() && x != 0 && y != 0 && isPrime(x) && isPrime(y)) { cout << "TAK"; return; } d *= 10; } cout << "NIE"; } int main() { ull n = 0; cin >> n; main3(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 38 39 40 41 42 43 44 45 | #include <iostream> #include <stdio.h> #include <string> #include <math.h> using namespace std; #define ull unsigned long long bool isPrime(ull n) { ull s = sqrt(n); for (int i = 2; i < s; ++i) if (n % i == 0) return false; return true; } void main3(ull n) { ull d = 10; ull x, y; while (n > d) { x = n / d; y = n % d; if (std::to_string(n).length() == std::to_string(x).length() + std::to_string(y).length() && x != 0 && y != 0 && isPrime(x) && isPrime(y)) { cout << "TAK"; return; } d *= 10; } cout << "NIE"; } int main() { ull n = 0; cin >> n; main3(n); return 0; } |