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
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <math.h>
#include <vector>
#include <iterator>
#include <algorithm>

using namespace std;

void solve() {
  double tt, b;
  int k, j, t;
  vector<int> fib;
  string r;
  
  b = sqrt(pow(10, 9)) + 1;
  ostream_iterator<int> show (cout, ", ");
  fib.push_back(1);
  fib.push_back(1);
  do {
    k = fib[fib.size() - 2] + fib[fib.size() - 1];
    fib.push_back(k);    
  } while(k < b);
  
  //copy(fib.begin(), fib.end(), show);
  
  cin >> t;
  for(int ii = 0; ii < t; ii++) {
    //cout << ii << "\t" << t << "\t";
    r = "NIE";
    cin >> b;
    
    if(b == 0) {
      cout << "TAK" << endl;
      continue;
    }    
    
    for(vector<int>::iterator n = fib.begin(); n != fib.end(); ++n) {
      tt = b / *n;
      if(int(tt) == tt && find(fib.begin(), fib.end(), tt) != fib.end()) {
        r = "TAK";
        //cout << b << "\t" << tt << "\t" << *n << endl;
        break;
      }
    }
    cout << r << endl;
  }  
}

int main() {

  solve();

  return 0;
}