#include <stdio.h> #include <math.h> bool isPrime(long long int n) { const auto to = sqrt(n); for (int i=2; i<=to; ++i) { if (n % i == 0) { return false; } } return true; } bool isSecond(long long int n, long long int div) { const auto value1 = n / div; const auto value2 = n % div; const auto value2HasNotLeadingZero = value2 * 10 >= div; return value2HasNotLeadingZero && isPrime(value1) && isPrime(value2); } int main(int, char **) { long long int n; scanf("%lld\n", &n); for (long long int i=10; i<=n; i *= 10) { if (isSecond(n, i)) { printf("TAK\n"); return 0; } } 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 | #include <stdio.h> #include <math.h> bool isPrime(long long int n) { const auto to = sqrt(n); for (int i=2; i<=to; ++i) { if (n % i == 0) { return false; } } return true; } bool isSecond(long long int n, long long int div) { const auto value1 = n / div; const auto value2 = n % div; const auto value2HasNotLeadingZero = value2 * 10 >= div; return value2HasNotLeadingZero && isPrime(value1) && isPrime(value2); } int main(int, char **) { long long int n; scanf("%lld\n", &n); for (long long int i=10; i<=n; i *= 10) { if (isSecond(n, i)) { printf("TAK\n"); return 0; } } printf("NIE\n"); return 0; } |