#include <cstdio> #include <cstring> #include <stdint.h> using namespace std; uint64_t a, b; char raw[20]; int n; void parse(int pos) { a = 0; b = 0; for (int i=0; i<pos; ++i) a = a*10 + (raw[i]-'0'); for (int i=pos; i<n; ++i) b = b*10 + (raw[i]-'0'); } bool isPrime(uint64_t n) { for (uint64_t a=2; a*a < n; ++a) { if (n % a == 0) return false; } return true; } int main() { scanf("%s", raw); n = strlen(raw); for (int i=1; i<n; ++i) { if (raw[i] == '0') continue; parse(i); if (isPrime(a) && isPrime(b)) { printf("TAK\n"); return 0; } } printf("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 30 31 32 33 34 35 | #include <cstdio> #include <cstring> #include <stdint.h> using namespace std; uint64_t a, b; char raw[20]; int n; void parse(int pos) { a = 0; b = 0; for (int i=0; i<pos; ++i) a = a*10 + (raw[i]-'0'); for (int i=pos; i<n; ++i) b = b*10 + (raw[i]-'0'); } bool isPrime(uint64_t n) { for (uint64_t a=2; a*a < n; ++a) { if (n % a == 0) return false; } return true; } int main() { scanf("%s", raw); n = strlen(raw); for (int i=1; i<n; ++i) { if (raw[i] == '0') continue; parse(i); if (isPrime(a) && isPrime(b)) { printf("TAK\n"); return 0; } } printf("NIE\n"); } |