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
#include<bits/stdc++.h>
using namespace std;

bool x[50000000];
unsigned long p = 2;

void sito(int k)
{
    k++;
    if(k > p){
    for(int i = p; i < k; i++)
        if(!x[i])
            for(int j = 2; i*j < k; j++)
                x[i*j] = 1;
    p = k;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    unsigned long s, sb = 0, a = 1, b, it = 1, w = 2;
    cin >> s;
    if(s%10 == 0 || s%10 == 4 || s%10 == 6 || s%10 == 8){
        cout << "NIE";
        return 0;
    }
    if(s%10 == 2 && (s%100 - s%10)/10 == 0 || (s%100 - s%10)/10 == 2 || (s%100 - s%10)/10 == 4 || (s%100 - s%10)/10 == 6 || (s%100 - s%10)/10 == 8){
        cout << "NIE";
        return 0;
    }
    for(int i = 10; i < s; i*=10){
        a = s%i;
        if(a >= i/10 ){
            b = s/i;
            if(w < max(a,b))
                w = max(a,b);
            sito(w);
            if(!x[a] && !x[b]){
                cout << "TAK";
                return 0;
            }
        }
    }
    cout << "NIE";
    return 0;
}