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
// zad_probne.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

vector<int> fibonacci(int max_wyr)
{
	vector<int> fib;
	fib.push_back(1);
	fib.push_back(1);
	while (fib.back() <= max_wyr)
	{
		fib.push_back(fib.back() + fib[fib.size()-2] );
	}
	return fib;
}

bool jest_suma_fib(int dana, const vector<int> & fib)
{
	if (dana==0)
		return true;
	for (int ii=0; ii<fib.size(); ii++)
	{
		if ((dana%fib[ii] ==0) && (binary_search(fib.begin(), fib.end(), dana/fib[ii])))
			return true;
	}
	return false;
}

int main()
{
	ios_base::sync_with_stdio(0);

	vector<int> fib = fibonacci( (int)pow(10,9) );
	
	//for(int ii = 0; ii<fib.size(); ++ii)
	//	cout<<fib[ii]<<' ';

	int ile;
	cin>>ile;

	for (int ii=1; ii<=ile; ii++)
	{
		int dana;
		cin>>dana;

		if (jest_suma_fib(dana, fib))
			cout<<"TAK"<<endl;   
		else
			cout<<"NIE"<<endl;   
		
		//cout<< (jest_suma_fib(dana, fib)) ?"TAK":"NIE";   
		

	}

	return 0;
}