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
/*
    Krzysztof Dziembała
*/
#include <iostream>

using namespace std;

inline bool IsPrime(int64_t number){
    if(((!(number & 1)) && number != 2) || (number < 2) || (number % 3 == 0 && number != 3))
        return (false);

    for(int64_t k = 1; 36*k*k-12*k < number; k++)
    if ((number % (6*k+1) == 0) || (number % (6*k-1) == 0))
        return (false);
    return true;

    //Source: https://stackoverflow.com/questions/4424374/determining-if-a-number-is-prime/4424496#4424496 (lekko zmodyfikowane i w stylu zgodnym z resztą programu)
}

int main(){
    int64_t lic;
    cin >> lic;
    int64_t i = 10;
    do{
        int64_t cz2 = lic%i;
        if((cz2 - lic%(i/10))){
            if(IsPrime(cz2)){
                int64_t cz1 = lic/i;
                if(IsPrime(cz1)){
                    cout << "TAK\n";
                    return 0;
                }
            }
        }
        i*=10;
    }while(i < lic);
    cout << "NIE\n";
    return 0;
}