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
#include <iostream>

using namespace std;

class ilo{
  public:
    int main ();
};

int ilo::main() {
  int i,j,k;
  int cnt;
  int val, half, dv, res;
  cin >> cnt;

  int max = 1;
  int fib_iter;
  int fib_max = 45;
  int fib_serie[fib_max];

  int vars[cnt];

  for(i=0; i<cnt; i++) {
    cin >> vars[i];
    if(vars[i]>max) max = vars[i];
  }

  for(fib_iter = 0; fib_iter < fib_max; fib_iter++) {
    if(fib_iter<2) fib_serie[fib_iter]=fib_iter;
    else fib_serie[fib_iter] = fib_serie[fib_iter-1] + fib_serie[fib_iter-2];

    if(fib_serie[fib_iter] > max) break;
  }

  for(i=0; i<cnt; i++) {
    res = 0;

    val = vars[i];
    half = val/2;

    for(j=fib_iter; j>2; j--) {
      if(fib_serie[j] == val) {
        res = 1;
        break;
      }
      if(fib_serie[j]>half) continue;
      if(val%fib_serie[j] == 0) {
        dv = val/fib_serie[j];
        for(k = j; k>0; k--) {
          if(dv == fib_serie[k]) {
            res =1;
            break;
          }
        }
      }
      if(res == 1) break;
    }

    if(res == 1) cout << "TAK\n";
    else cout << "NIE\n";
  }







  return 0;
}

int main() {
  ilo *t = new ilo();
  t->main();
}