#include<bits/stdc++.h> using namespace std; typedef long long ll; #define PB push_back const int maxn=1e6+1; vector<ll> p; void sito() { bool v[maxn]; for(int i=0; i < maxn; i++) { v[i] = true; } for(int i=2; i*i < maxn; i++) { if(v[i]) for(int j=i*i; j < maxn; j+=i) { v[j] = false; } } for(int i=2; i < maxn; i++) { if(v[i]) p.PB(i); } } bool isPrime(ll a) { if(a==1) return false; for(int i=0; p[i]*p[i] <= a; i++) { if(a%p[i]==0) return false; } return true; } int main() { ios_base::sync_with_stdio(0); ll n; cin >> n; sito(); ll d=10; bool czy = false; while(n >= d) { if((n%d)*10 >= d && isPrime(n/d) && isPrime(n%d)) { czy=true; break; } d*=10; } if(czy) { cout << "TAK\n"; } else { cout << "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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | #include<bits/stdc++.h> using namespace std; typedef long long ll; #define PB push_back const int maxn=1e6+1; vector<ll> p; void sito() { bool v[maxn]; for(int i=0; i < maxn; i++) { v[i] = true; } for(int i=2; i*i < maxn; i++) { if(v[i]) for(int j=i*i; j < maxn; j+=i) { v[j] = false; } } for(int i=2; i < maxn; i++) { if(v[i]) p.PB(i); } } bool isPrime(ll a) { if(a==1) return false; for(int i=0; p[i]*p[i] <= a; i++) { if(a%p[i]==0) return false; } return true; } int main() { ios_base::sync_with_stdio(0); ll n; cin >> n; sito(); ll d=10; bool czy = false; while(n >= d) { if((n%d)*10 >= d && isPrime(n/d) && isPrime(n%d)) { czy=true; break; } d*=10; } if(czy) { cout << "TAK\n"; } else { cout << "NIE\n"; } return 0; } |