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
#include <cstdio>
#include <vector>

const int MLD = 1000000005;
long long x,fib[50];
std::vector<long long> mult;
int t;

void init();
bool find(long long);

int main()
{
	init();
	scanf("%d", &t);
	while(t--)
	{
		scanf("%lld", &x);
		if(find(x)) printf("TAK\n");
		else printf("NIE\n");
	}
}

void init()
{
	long long tmp, a = 0, b = 1, num = 2;
	fib[0] = 0; fib[1] = 1;

	while(b < MLD)
	{
		tmp = a+b;
		a = b; b = tmp;
		fib[num] = tmp;
		num++;
	}

	for(int i = 0; i < num; ++i)
		for(int j = i; j < num; ++j)
		{
			tmp = fib[i]*fib[j];
			if(tmp < MLD) mult.push_back(tmp);
		}
}

bool find(long long x)
{
	for(int i = 0; i < mult.size(); ++i)
		if(x == mult[i]) return true;
	return false;
}