#include<iostream>
#include<assert.h>
#include<cstdio>
#include<string>
#include<cmath>
#include<bitset>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
#define FOR(I,A,B) for(int I=(A);I<=(B);I++)
#define REP(I,N) for(int I=0;I<(N);I++)
#define ALL(X) (X).begin(),(X).end()
#define PB push_back
#define MP make_pair
#define f first
#define s second
//#define DEBUG true
#ifdef DEBUG
#define SHOW(NAME, VAL) cout << NAME << ": " << VAL << '\n'
#else
#define SHOW(NAME, VAL)
#endif
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;
typedef vector<string> VS;
bool is_prime(ll number) {
if(number <= 1) {
return false;
}
FOR(d, 2, sqrt(number)) {
if(number % d == 0) {
return false;
}
}
return true;
}
ll value_of(VI digits) {
ll value = 0;
for(auto d : digits) {
value *= 10;
value += d;
}
return value;
}
void test() {
ll n;
cin >> n;
VI right;
while(n) {
right.PB(n % 10);
n /= 10;
}
reverse(ALL(right));
VI left;
while(right.size() > 1) {
left.PB(right[0]);
right.erase(right.begin());
if(right[0] != 0 && is_prime(value_of(left)) && is_prime(value_of(right))) {
cout << "TAK\n";
return;
}
}
cout << "NIE\n";
}
int main() {
int t;
t = 1;
// cin >> t;
FOR(i, 1, t) {
test();
}
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #include<iostream> #include<assert.h> #include<cstdio> #include<string> #include<cmath> #include<bitset> #include<vector> #include<map> #include<set> #include<algorithm> #include<utility> using namespace std; #define FOR(I,A,B) for(int I=(A);I<=(B);I++) #define REP(I,N) for(int I=0;I<(N);I++) #define ALL(X) (X).begin(),(X).end() #define PB push_back #define MP make_pair #define f first #define s second //#define DEBUG true #ifdef DEBUG #define SHOW(NAME, VAL) cout << NAME << ": " << VAL << '\n' #else #define SHOW(NAME, VAL) #endif typedef vector<int> VI; typedef pair<int,int> PII; typedef long long ll; typedef vector<string> VS; bool is_prime(ll number) { if(number <= 1) { return false; } FOR(d, 2, sqrt(number)) { if(number % d == 0) { return false; } } return true; } ll value_of(VI digits) { ll value = 0; for(auto d : digits) { value *= 10; value += d; } return value; } void test() { ll n; cin >> n; VI right; while(n) { right.PB(n % 10); n /= 10; } reverse(ALL(right)); VI left; while(right.size() > 1) { left.PB(right[0]); right.erase(right.begin()); if(right[0] != 0 && is_prime(value_of(left)) && is_prime(value_of(right))) { cout << "TAK\n"; return; } } cout << "NIE\n"; } int main() { int t; t = 1; // cin >> t; FOR(i, 1, t) { test(); } return 0; } |
English