#include <cstdio> #include <cstring> bool isPrime(long long s) { if (s <= 1) return false; for (long long i = 2LL; i * i <= s; i++) { if (s % i == 0) { return false; } } return true; } int main() { long long n; scanf("%lld", &n); long long suf = 0LL; long long pref = n; long long pw = 1LL; while (n > 0) { pref = n / 10LL; if (pref == 0) break; suf = pw * (n % 10LL) + suf; pw *= 10LL; //printf("%lld %lld\n", pref, suf); if (n % 10LL) { //printf("%lld %lld\n", pref, suf); if (isPrime(pref) && isPrime(suf)) { //printf("%lld %lld\n", pref, suf); printf("TAK\n"); return 0; } } n /= 10LL; } printf("NIE\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 46 47 48 49 50 | #include <cstdio> #include <cstring> bool isPrime(long long s) { if (s <= 1) return false; for (long long i = 2LL; i * i <= s; i++) { if (s % i == 0) { return false; } } return true; } int main() { long long n; scanf("%lld", &n); long long suf = 0LL; long long pref = n; long long pw = 1LL; while (n > 0) { pref = n / 10LL; if (pref == 0) break; suf = pw * (n % 10LL) + suf; pw *= 10LL; //printf("%lld %lld\n", pref, suf); if (n % 10LL) { //printf("%lld %lld\n", pref, suf); if (isPrime(pref) && isPrime(suf)) { //printf("%lld %lld\n", pref, suf); printf("TAK\n"); return 0; } } n /= 10LL; } printf("NIE\n"); return 0; } |