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

typedef unsigned long long FibNumber;

std::string checkFib(const std::vector<FibNumber>& fibs, const unsigned long number)
{
  if(number == 0)
  {
    return std::string("TAK");
  }
  for(auto n1 = fibs.begin(); n1 != fibs.end() && *n1 <= number; ++n1)
  {
    for(auto n2 = n1; n2 != fibs.end() && *n2 <= number; ++n2)
    {
      if(number % *n1 == 0 && number / *n1 == *n2)
      {
        return std::string("TAK");
      }
    }
  }
  return std::string("NIE");
} 

int main(int argc, char** argv)
{
  std::vector<FibNumber> fibs;

  unsigned long long elem(0);
  fibs.push_back(1);
  fibs.push_back(2); 
  
  while (elem < 10000000000L)
  {
    elem = fibs[fibs.size() - 1] + fibs[fibs.size() - 2];
    fibs.push_back(elem);
  }

  
  std::ios_base::sync_with_stdio(0);

  int t;
  std::cin>>t;
  while(t--)
  {
    unsigned long long number;
    std::cin>>number;
    std::cout<<checkFib(fibs, number)<<std::endl;
  }
  return 0;
}