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
#include <iostream>
#include <string>
using namespace std;
bool Test(string liczba)
{
     bool test;
    for(int i=0;i<liczba.length();i++)
    {

        if(liczba[i]==2 || liczba[i]==3 || liczba[i]==5 || liczba[i]==7 || liczba[i]==0 || liczba[i]==1)
            test = false;
    }
    return test;
}
bool CzyPierwsza(string liczba)
{
       bool test;
       long long int s = stoll(liczba);
    for( long long int i=1;i*i<s;i++)
    {

        if(s % i == 0)
            test = false;
    }
    return test;

}
int main()
{   string liczba;
    cin>>liczba;
    if(liczba.length()>1)
    {
        if(Test(liczba))
        {
            if(CzyPierwsza(liczba))
            {
                cout << "TAK" << endl;
            }
            else
            {
                cout << "NIE" << endl;
            }
        }

        else
            cout << "NIE" << endl;
    }
    else
        cout << "NIE" << endl;

    return 0;
}