#include <iostream> #include <cmath> using namespace std; bool is_prime(long long p) { if(p<2)return false; if(p==2)return true; for(long long i =2;i<sqrt(p);i++){ if(p%i ==0) return false; } return true; } bool liczba_druga(long long p) { long long M = 10; while(true) { long long x = p%M; long long y = p/M; if(x*10 > M){ if(y < 2)break; // cout<<x<<" "<<y<<"\n"; if(is_prime(x) && is_prime(y)){ return true; } } if(y < 2)break; M*=(long long)10; } return false; } int main(){ long long p; cin>>p; if( liczba_druga(p)){ 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 | #include <iostream> #include <cmath> using namespace std; bool is_prime(long long p) { if(p<2)return false; if(p==2)return true; for(long long i =2;i<sqrt(p);i++){ if(p%i ==0) return false; } return true; } bool liczba_druga(long long p) { long long M = 10; while(true) { long long x = p%M; long long y = p/M; if(x*10 > M){ if(y < 2)break; // cout<<x<<" "<<y<<"\n"; if(is_prime(x) && is_prime(y)){ return true; } } if(y < 2)break; M*=(long long)10; } return false; } int main(){ long long p; cin>>p; if( liczba_druga(p)){ cout<<"TAK\n"; } else{ cout<<"NIE\n"; } return 0; } |