#include<iostream>
using namespace std;
string n;
long long a,b;
int lng, m[14];
bool odp;
bool czyp(long long x){
for(long long i=2;i*i<=x;++i){
if(x%i==0)
return false;
}
return true;
}
int main(){
cin>>n;
lng=n.size();
for(int i=0;i<lng;++i)
m[i]=n[i]-'0';
int i=0;
while(i<lng-1){
if(m[i+1]==0){
++i;
continue;
}
a=m[0];
for(int j=1;j<=i;++j){
a*=10;
a+=m[j];
}
b=m[i+1];
for(int j=i+2;j<lng;++j){
b*=10;
b+=m[j];
}
if(czyp(a)==1 && czyp(b)==1){
odp=true;
break;
}
a=0;
b=0;
++i;
}
if(odp)
cout<<"TAK";
else
cout<<"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 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 | #include<iostream> using namespace std; string n; long long a,b; int lng, m[14]; bool odp; bool czyp(long long x){ for(long long i=2;i*i<=x;++i){ if(x%i==0) return false; } return true; } int main(){ cin>>n; lng=n.size(); for(int i=0;i<lng;++i) m[i]=n[i]-'0'; int i=0; while(i<lng-1){ if(m[i+1]==0){ ++i; continue; } a=m[0]; for(int j=1;j<=i;++j){ a*=10; a+=m[j]; } b=m[i+1]; for(int j=i+2;j<lng;++j){ b*=10; b+=m[j]; } if(czyp(a)==1 && czyp(b)==1){ odp=true; break; } a=0; b=0; ++i; } if(odp) cout<<"TAK"; else cout<<"NIE"; return 0; } |
English