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
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <stdlib.h>

#define INPUT_FILE "./ilo"
#define BUF_SIZE 16

void ilo(unsigned int *n, int t)
{
	unsigned int fib11, fib12, fib21, fib22;
	unsigned int max = 0;
	int i = 0;
	int *out;
	
	out = (int *) calloc(t, sizeof(unsigned int));
	
	for (i = 0; i < t; i++)
	{
		if (0 == n[i])
			out[i] = 1;
		
		if (n[i] > max)
			max = n[i];
	}
	
	for (fib11 = 1, fib12 = 2; fib11 * fib11 <= max; fib12 += fib11, fib11 = fib12 - fib11)
		for (fib21 = fib11, fib22 = fib12; fib11 * fib21 <= max; fib22 += fib21, fib21 = fib22 - fib21)
			for (i = 0; i < t; i++)
				if (!out[i])
					if (fib11 * fib21 == n[i])
						out[i] = 1;
	
	for (i = 0; i < t; i++)
	{
		if (out[i])
			printf("TAK\n");
		else
			printf("NIE\n");
	}
}

int main(int argc, char **argv)
{
	char buf[BUF_SIZE];
	int t;
	unsigned int *n;
	
	sscanf(fgets(buf, BUF_SIZE, stdin), "%d", &t);
	
	n = (unsigned int *) calloc(t, sizeof(unsigned int));
	t = 0;

	while (fgets(buf, BUF_SIZE, stdin))
		sscanf(buf, "%u", &n[t++]);
	
	ilo(n, t);
	
	return 0;
}