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
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    long long int ld = 0, licz = 10, buf1 = 0, buf2 = 0, buf3=0, liczBuf1 = 0, liczBuf2 = 0;
    bool smiec = false;
    bool isbuf1 = false;
    bool isbuf2 = false;
    cin>> ld;
    {
        while(true){
            buf1 = ld%licz;
            buf2 = (ld-buf1)/licz;
            buf3=ld%(licz/10);
            for(int i=2; i<sqrt(ld); ++i){
                if(buf1%i == 0 && buf1 != i){
                    liczBuf1++;
                }
                if(buf2%i == 0 && buf2 != i){
                    liczBuf2++;
                }
            }
            if(buf1!=buf3 && liczBuf1 == 0 && liczBuf2 == 0){
                cout<<"TAK";
                break;
            }
            liczBuf1 = 0;
            liczBuf2 = 0;
            licz *= 10;
            if(licz > ld){
                cout<<"NIE";
                break;
            }
        }
    }
    return 0;
}