#include <cstdio> using namespace std; bool testPrime(long long int p) { if(p<2) return false; for(long long int i=2;i*i<=p;i++) if(!(p%i)) return false; return true; } bool test2Prime(long long int n) { for(long long int i=10;i<n;i*=10) { if(n%i == n%(i/10)) continue; bool r1 = testPrime(n%i); bool r2 = testPrime(n/i); if(r1 && r2) return true; } return false; } int main() { long long int n; scanf("%lld",&n); printf("%s",test2Prime(n) ? "TAK" : "NIE"); 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 | #include <cstdio> using namespace std; bool testPrime(long long int p) { if(p<2) return false; for(long long int i=2;i*i<=p;i++) if(!(p%i)) return false; return true; } bool test2Prime(long long int n) { for(long long int i=10;i<n;i*=10) { if(n%i == n%(i/10)) continue; bool r1 = testPrime(n%i); bool r2 = testPrime(n/i); if(r1 && r2) return true; } return false; } int main() { long long int n; scanf("%lld",&n); printf("%s",test2Prime(n) ? "TAK" : "NIE"); return 0; } |