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
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <stdlib.h>

using namespace std;

bool isPrimeNumber(long long input)
{
    for(long long i = 2; i < input/2; i++)
    {
        if(input % i == 0)
            return false;
    }
    return true;
}

int main()
{
    long long input;
    string number;

    scanf("%lld", &input);

    if(input < 10)
    {
        cout << "NIE";
        return 0;
    }

    stringstream stream;

    stream << input;
    stream >> number;

    for(unsigned int i = 1; i < number.length(); i++)
    {
        string firstHalf = number.substr(0, i);
        string secondHalf = number.substr(i, number.length() - i);

        if(secondHalf[0] == '0') continue;

        long long firstHalfInput = atol(firstHalf.c_str());
        long long secondHalfInput = atol(secondHalf.c_str());

        if(isPrimeNumber(firstHalfInput))
        {
            if(isPrimeNumber(secondHalfInput))
            {
                cout << "TAK";
                return 0;
            }
        }
    }

    cout << "NIE";
    return 0;
}