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
#include <cstdio>
#include <cmath>

bool is_product_fibo(unsigned int n){
	unsigned int sum = round((log(5 * static_cast<double>(n))) / (log((1 + sqrt(5))/2)));
	unsigned int a, b;
	for (int i = 0; i <= sum - i; i++){
		a = round((1.0 / sqrt(5))*pow((1 + sqrt(5)) / 2, i));
		b = round((1.0 / sqrt(5))*pow((1 + sqrt(5)) / 2, sum - i));
		if (a*b == n) return true;
	}
	return false;
}

int main(){
	unsigned int n;
	int i;
	scanf("%d", &n);
	unsigned int *tab = new unsigned int[n];
	for (i = 0; i < n; i++){
		scanf("%d", &tab[i]);
	}
	for (i = 0; i < n; i++){
		printf("%s\n", (is_product_fibo(tab[i]) == true ? "TAK" : "NIE"));
	}
	delete []tab;
	return 0;
}