#include <vector>
#include <iostream>
#include <algorithm>
#ifndef d
#define d(...)
#endif
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<typename t>using V=vector<t>;
inline bool prime ( ll n )
{
for ( ll i = 2; i * i <= n; ++i )
if ( ( n % i ) == 0 )
return false;
return true;
}
inline bool foo ( string& a )
{
for ( int i = 1; i < a.size(); ++i )
if ( a[i] != '0' and
prime( stoll( a.substr( 0, i ) ) ) and
prime( stoll( a.substr( i ) ) ) )
return true;
return false;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n; cin >> n;
string a = to_string( n );
cout << ( foo( a )? "TAK" : "NIE" ) << '\n';
}
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 | #include <vector> #include <iostream> #include <algorithm> #ifndef d #define d(...) #endif #define ALL(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef unsigned long long ull; template<typename t>using V=vector<t>; inline bool prime ( ll n ) { for ( ll i = 2; i * i <= n; ++i ) if ( ( n % i ) == 0 ) return false; return true; } inline bool foo ( string& a ) { for ( int i = 1; i < a.size(); ++i ) if ( a[i] != '0' and prime( stoll( a.substr( 0, i ) ) ) and prime( stoll( a.substr( i ) ) ) ) return true; return false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; string a = to_string( n ); cout << ( foo( a )? "TAK" : "NIE" ) << '\n'; } |
English