#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <time.h>
#include <queue>
typedef long long int64;
using namespace std;
bool is_prime(int64 n) {
if (n <= 1) {
return false;
}
int64 d = 2;
while (d * d <= n && d < n) {
if (n % d == 0) {
return false;
}
++d;
}
return true;
}
int main () {
int64 n;
scanf("%lld", &n);
int64 p = 1;
for (int i = 0; i < 13; ++i) {
p *= 10;
int64 second = n % p;
int64 first = (n - second) / p;
if (second * 10 >= p && first > 0 && is_prime(second) && is_prime(first)) {
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 40 41 42 43 | #include <cstdio> #include <cstdlib> #include <vector> #include <map> #include <algorithm> #include <set> #include <time.h> #include <queue> typedef long long int64; using namespace std; bool is_prime(int64 n) { if (n <= 1) { return false; } int64 d = 2; while (d * d <= n && d < n) { if (n % d == 0) { return false; } ++d; } return true; } int main () { int64 n; scanf("%lld", &n); int64 p = 1; for (int i = 0; i < 13; ++i) { p *= 10; int64 second = n % p; int64 first = (n - second) / p; if (second * 10 >= p && first > 0 && is_prime(second) && is_prime(first)) { printf("TAK\n"); return 0; } } printf("NIE\n"); return 0; } |
English