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

inline bool is_prime(unsigned long long number) {
	if (number == 2) {
		return true;
	}
	unsigned long long square_root = round(sqrt(number)), reminder = 0;
	for (unsigned long long divisor = 2; divisor <= square_root; divisor++) {
		reminder = number % divisor;
		if (reminder == 0) {
			break;
		}
	}
	return(reminder != 0);
}

int main() {
	unsigned long long number = 0, nums[2] = { 0, 0 };
	unsigned int num_lenght;
	bool answer = false;
	cin >> number;
	num_lenght = to_string(number).length();
	for (unsigned int i = 1; i < num_lenght; i++) {
		nums[0] = number % static_cast<unsigned long long>(round(pow(10, i)));
		nums[1] = number / static_cast<unsigned long long>(round(pow(10, i)));
		if (nums[0] < static_cast<unsigned long long>(round(pow(10, i - 1))) || any_of(&nums[0], &nums[1], [](unsigned long long num) {return num == 0 || num == 1; })) {
			continue;
		}
		if (answer = is_prime(nums[0]) && is_prime(nums[1])) {
			break;
		}
	}
	cout << (answer ? "TAK" : "NIE") << endl;
	return 0;
}