#include <bits/stdc++.h>
using namespace std;
#ifndef _WIN32
#define getchar getchar_unlocked
#endif
#define MP make_pair
#define PB push_back
#define ST first
#define ND second
typedef long long int LLI;
typedef unsigned long long int LLU;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<int> vi;
template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
while(*sdbg!=',') cerr<<*sdbg++;
cerr<<"="<<h<<",";
_dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
bool pierwsze(string s){
if(s[0] == '0') return 0;
LLI x; stringstream ss(s); ss >> x;
if(x == 1) return 0;
for(int i = 2; LLI(i)*i <= x; ++i)
if(x % i == 0) return 0;
return 1;
}
int32_t main()
{
string in; cin >> in;
for(int i = 0; i < int(in.length()) - 1; ++i)
if(pierwsze(in.substr(0, i + 1)) && pierwsze(in.substr(i + 1, in.length() - i - 1))) return cout << "TAK", 0;
cout << "NIE";
}
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 | #include <bits/stdc++.h> using namespace std; #ifndef _WIN32 #define getchar getchar_unlocked #endif #define MP make_pair #define PB push_back #define ST first #define ND second typedef long long int LLI; typedef unsigned long long int LLU; typedef long double LD; typedef pair<int, int> pii; typedef pair<long long int, long long int> pll; typedef vector<int> vi; template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";} template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) { while(*sdbg!=',') cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, a...); } #define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__) #define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) bool pierwsze(string s){ if(s[0] == '0') return 0; LLI x; stringstream ss(s); ss >> x; if(x == 1) return 0; for(int i = 2; LLI(i)*i <= x; ++i) if(x % i == 0) return 0; return 1; } int32_t main() { string in; cin >> in; for(int i = 0; i < int(in.length()) - 1; ++i) if(pierwsze(in.substr(0, i + 1)) && pierwsze(in.substr(i + 1, in.length() - i - 1))) return cout << "TAK", 0; cout << "NIE"; } |
English