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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <cstdio>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>

typedef long long lLong;
typedef unsigned long uLong;
typedef unsigned long long ulLong;
typedef unsigned int uInt;
typedef unsigned char Byte;

using namespace std;

#define FOR(x, b, e) for(int x=b; x<=(e); ++x)
#define ALL(i) (i).begin(), (i).end()
#define CONTAINS(i,v) (find(ALL(i),v)!=(i).end())
typedef vector<bool> bit_vector;
typedef vector<ulLong> VI;
typedef vector<ulLong> VLL;

const ulLong maxN = 10000000005UL;

VLL fibTab;

inline void GenerujTabliceLiczbFib()
{
	fibTab.clear();
	fibTab.push_back(0);
	fibTab.push_back(1);	
	int i = 2;
	ulLong curFib=fibTab[0]+fibTab[1];
	while(curFib<=maxN)
	{
		fibTab.push_back(curFib);		
		i++;
		curFib = fibTab[i-1]+fibTab[i-2];		
		//cout << i <<": " << curFib <<"\n";		
	}
}

bool SprawdzCzyMoznaZapisacJakoIlocznFib(ulLong liczba)
{
	bool zwrot=false;
	if(liczba<=3)
	{
		zwrot = true;
	}
	else
	{
		ulLong liczbaPrim;
		int i=2;
		while(fibTab[i]<liczba) 
		{			
			if(liczba%fibTab[i]==0)
			{
				liczbaPrim = liczba/fibTab[i];
				if(CONTAINS(fibTab,liczbaPrim))
				{
					zwrot = true;
					break;
				}				
			}
			i++;
		}
	}
	return zwrot;
}

int main(int argc, char **argv)
{		
	int t;
	ulLong n;	
	GenerujTabliceLiczbFib();
	scanf("%d\n",&t);	

	for(int i=0;i<t;i++)
	{	
		scanf("%lld",&n);
		
		if(SprawdzCzyMoznaZapisacJakoIlocznFib(n))
		{
			printf("TAK\n");
		}
		else
		{
			printf("NIE\n");
		}
	}		
	return 0;
}