#include<bits/stdc++.h> #define endl '\n' using namespace std; string n; long long v, w; bool prime( long long x ) { if( x == 1 || x == 0 )return 0; for( long long a = 2; a*a <= x; a++ ) { if( x%a == 0 )return 0; } return 1; } int main() { ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cin>>n; for( int a = 0; a+1 < n.size(); a++ ) { if( n[a+1] == '0' )continue; v = 0, w = 0; for( int b = 0; b <= a; b++ )v *= 10, v += int(n[b]-'0'); for( int b = a+1; b < n.size(); b++ )w *= 10, w += int(n[b]-'0'); if( prime(v) && prime(w) ) { cout<<"TAK"; return 0; } } 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 | #include<bits/stdc++.h> #define endl '\n' using namespace std; string n; long long v, w; bool prime( long long x ) { if( x == 1 || x == 0 )return 0; for( long long a = 2; a*a <= x; a++ ) { if( x%a == 0 )return 0; } return 1; } int main() { ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cin>>n; for( int a = 0; a+1 < n.size(); a++ ) { if( n[a+1] == '0' )continue; v = 0, w = 0; for( int b = 0; b <= a; b++ )v *= 10, v += int(n[b]-'0'); for( int b = a+1; b < n.size(); b++ )w *= 10, w += int(n[b]-'0'); if( prime(v) && prime(w) ) { cout<<"TAK"; return 0; } } cout<<"NIE"; return 0; } |