#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
ll n;
bool s[3200007];
vector<ll> primes;
bool prime(ll x) {
if(x < 2)
return false;
for(int i = 0 ; primes[i] * primes[i] <= x ; i++)
if(x % primes[i] == 0)
return false;
return true;
}
int main() {
for(int i = 2 ; i * i <= 3200000 ; i++)
if(!s[i])
for(int j = i * i ; j <= 3200000 ; j += i)
s[j] = true;
for(int i = 2 ; i <= 3200000 ; i++)
if(!s[i])
primes.push_back(i);
scanf("%lld", &n);
ll pot = 10;
while(n / pot) {
ll a = n / pot;
ll b = n % pot;
if(b / (pot / 10LL) == 0) {
pot *= 10LL;
continue;
}
if(prime(a) && prime(b)) {
printf("TAK\n");
return 0;
}
pot *= 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 51 52 53 54 55 56 | #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; ll n; bool s[3200007]; vector<ll> primes; bool prime(ll x) { if(x < 2) return false; for(int i = 0 ; primes[i] * primes[i] <= x ; i++) if(x % primes[i] == 0) return false; return true; } int main() { for(int i = 2 ; i * i <= 3200000 ; i++) if(!s[i]) for(int j = i * i ; j <= 3200000 ; j += i) s[j] = true; for(int i = 2 ; i <= 3200000 ; i++) if(!s[i]) primes.push_back(i); scanf("%lld", &n); ll pot = 10; while(n / pot) { ll a = n / pot; ll b = n % pot; if(b / (pot / 10LL) == 0) { pot *= 10LL; continue; } if(prime(a) && prime(b)) { printf("TAK\n"); return 0; } pot *= 10LL; } printf("NIE\n"); return 0; } |
English