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

using namespace std;

bool IsPrime(unsigned long num)
{
	for (unsigned long i = 2; i < num; i++)
	{
		if (num % i == 0)
		{
			return false;
		}
	}
	return true;
}

bool IsPrime(string s_num)
{
	unsigned long num = stoul(s_num, NULL, 0);
	return IsPrime(num);
}

bool IsDRU(unsigned long num)
{
	string s_num = to_string(num);
	unsigned short len = (unsigned short)s_num.length();

	for (int i = 1; i < len; i++)
	{
		if (IsPrime(s_num.substr(0, i)) && IsPrime(s_num.substr(i, len - i)))
		{
			return true;
		}
	}
	return false;
}

int main()
{
	unsigned long num;
	cin >> num;
	string result;
	result = IsDRU(num) ? "TAK" : "NIE";
	cout << result;
}