#include <bits/stdc++.h> using namespace std; #define V vector #define LL long long #define U unsigned #define LD long double #define PII pair<int,int> #define F first #define S second #define E emplace #define EB emplace_back #define OS ostream #define IS istream #define all(x) x.begin(), x.end() #define FOR(i, a, b) for(decltype(b) i = a; i < b; i++) #define FORE(i, a, b) for(decltype(b) i = a; i <= b; i++) template <class T> void P(T a) {cout << a;} template <class T, class... Args> void P(T a, Args... args){cout << a; P(args...);} bool SHOWSTUFF = true; #ifdef DEBUG #define SH(...) if(SHOWSTUFF){__VA_ARGS__} #else #define SH(...) #endif // DEBUG template <class A, class B> OS& operator<<(OS& os, pair<A,B> p){P("(", p.F, ", ", p.S, ")"); return os;} #define OO(A) template <class... T> OS& operator<<(OS& os, const A<T...> t){P("{"); for(auto&& i : t) P(i, " "); P("}");return os;} OO(V) OO(map) OO(set) OO(deque) #define NL SH(cout << endl;) #define L(a) SH(P(#a, " = ", a, " ");) #define LN(a) SH(P(#a, " = ", a); NL) template <class T> void wNl(T t) { auto a = t.begin(); auto b = t.end(); P("{\n"); for(auto c = a; a != b;a++) P(distance(c, a), ": ", *a, '\n'); P("}"); NL } #define LOG(a) SH(P(#a, " = "); wNl(a);) #define INF ((int)1e9 + 696969) //################################################################################################## bool isPrime(LL a) { for(long long d = 2; d *d <= a; d++) if(a%d == 0) return false; return true; } int main() { #ifndef DEBUG ios_base::sync_with_stdio(false); cin.tie(0); #endif // DEBUG string n; cin >> n; FORE(l, 1, n.size() - 1) { string aString = n.substr(0, l); string bString = n.substr(l, n.size() - l); NL LN(aString) LN(bString) if(aString[0] == '0' || bString[0] == '0') continue; LL a = atoll(aString.c_str()); LL b = atoll(bString.c_str()); LN(a) LN(b) if(isPrime(a) && isPrime(b)) return cout << "TAK\n", 0; } return cout << "NIE\n", 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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | #include <bits/stdc++.h> using namespace std; #define V vector #define LL long long #define U unsigned #define LD long double #define PII pair<int,int> #define F first #define S second #define E emplace #define EB emplace_back #define OS ostream #define IS istream #define all(x) x.begin(), x.end() #define FOR(i, a, b) for(decltype(b) i = a; i < b; i++) #define FORE(i, a, b) for(decltype(b) i = a; i <= b; i++) template <class T> void P(T a) {cout << a;} template <class T, class... Args> void P(T a, Args... args){cout << a; P(args...);} bool SHOWSTUFF = true; #ifdef DEBUG #define SH(...) if(SHOWSTUFF){__VA_ARGS__} #else #define SH(...) #endif // DEBUG template <class A, class B> OS& operator<<(OS& os, pair<A,B> p){P("(", p.F, ", ", p.S, ")"); return os;} #define OO(A) template <class... T> OS& operator<<(OS& os, const A<T...> t){P("{"); for(auto&& i : t) P(i, " "); P("}");return os;} OO(V) OO(map) OO(set) OO(deque) #define NL SH(cout << endl;) #define L(a) SH(P(#a, " = ", a, " ");) #define LN(a) SH(P(#a, " = ", a); NL) template <class T> void wNl(T t) { auto a = t.begin(); auto b = t.end(); P("{\n"); for(auto c = a; a != b;a++) P(distance(c, a), ": ", *a, '\n'); P("}"); NL } #define LOG(a) SH(P(#a, " = "); wNl(a);) #define INF ((int)1e9 + 696969) //################################################################################################## bool isPrime(LL a) { for(long long d = 2; d *d <= a; d++) if(a%d == 0) return false; return true; } int main() { #ifndef DEBUG ios_base::sync_with_stdio(false); cin.tie(0); #endif // DEBUG string n; cin >> n; FORE(l, 1, n.size() - 1) { string aString = n.substr(0, l); string bString = n.substr(l, n.size() - l); NL LN(aString) LN(bString) if(aString[0] == '0' || bString[0] == '0') continue; LL a = atoll(aString.c_str()); LL b = atoll(bString.c_str()); LN(a) LN(b) if(isPrime(a) && isPrime(b)) return cout << "TAK\n", 0; } return cout << "NIE\n", 0; } |