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

using namespace std;

const unsigned int fibNumCount = 47;

int main() {
	int maxValue = 1000000000;
	
	vector<unsigned int> fibNum(fibNumCount);
	fibNum[0] = 0;
	fibNum[1] = 1;
	for (unsigned int i=2; i<fibNumCount; ++i) {
		fibNum[i] = fibNum[i-1] + fibNum[i-2];
	}
	
	unsigned int n, number;
	scanf("%d", &n);
	
	for (unsigned int i=0; i<n; ++i) {
		scanf("%d", &number);
		bool result = false;
		for (unsigned int j = 0; j < fibNumCount; ++j) {
			if (fibNum[j] > number)
				break;
				
			for (unsigned int k = 0; k < fibNumCount; ++k) {
				if (j>0 && maxValue / fibNum[j] < fibNum[k])
					break;

				if (fibNum[j] * fibNum[k] == number) {
					result = true;
				}
			}
		}

		if (result)
			printf("TAK\n");
		else
			printf("NIE\n");
	}
	
	return 0;
}