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
#include <iostream>
using namespace std;

const int fibN = 44;
/*
 * nieujemne liczby fibonacciego bez powtórzeń
 */
int fib[fibN];

int main() {
  for(int a=0,b=1,i=0; i<fibN; i++) {
    int temp = a+b;
    a=b;
    b=temp;
    fib[i] = b;
  }

  int n;
  cin >> n;
  for(;n>0; n--) {
    int k;
    cin >> k;
    bool found = false;
    if(k==0) found = true;
    for(int i=0; i<fibN && k >= fib[i] && !found; i++)
      if(k % fib[i] == 0) {
	int d = k/fib[i];
	for(int j=0; j<fibN && fib[j] <= d && !found; j++)
	  if(fib[j] == d) found = true;
      }
    if(found) cout << "TAK" << endl;
    else cout << "NIE" << endl;
  }

  return 0;
}