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 <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> fibValues = { 1 };
void FibCreator()
{
	unsigned long long newValue = 1;
	do
	{
		fibValues.push_back(newValue);
		newValue = *fibValues.rbegin() + *(++fibValues.rbegin());
	} while (newValue < 1000000000L);
}

int main()
{
	int n, s;
	FibCreator();
	scanf("%d", &n);
	while (n--)
	{
		scanf("%d", &s);
		if (s == 0)
		{
			puts("TAK");
		}
		else
		{
			bool result = false;
			for (const auto& a : fibValues)
			{
				if (s % a == 0)
				{
					result |= binary_search(fibValues.begin(), fibValues.end(), s / a);
					if (result) break;
				}
			}
			puts(result ? "TAK" : "NIE");
		}
	}

	return 0;
}