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
#include <cstdio>
#include <set>
using namespace std;

static void fillFibo(set<int>& fibo) 
{
	int a, b, c;
	a = 0;
	b = 1;
	c = 1;
	while (c <= 1000000000) {
		fibo.insert(c);
		a = b;
		b = c;
		c = a + b;
	}
}

static bool isIlo(int n, const set<int>& fibo)
{
	if (n == 0)
		return true;

	for (set<int>::iterator it = fibo.begin(); it != fibo.end(); ++it) {
		if (n < *it) {
			return false;
		}
		if (((n % *it) == 0) && fibo.find(n / *it) != fibo.end()) {
			return true;
		}
	}
	return false;
}

int main()
{
	set<int> fibo;
	fillFibo(fibo);

	int t, n;
	scanf("%d", &t);
	while (t--) {
		scanf("%d", &n);
		printf("%s\n", isIlo(n, fibo) ? "TAK" : "NIE");
	}

	return 0;
}