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

#define COUNT 46

void gen_fib(int * tab)
{
  tab[0]=0;
  tab[1]=1;
  for (int i=2; i < COUNT; i++)
  {
    tab[i]= tab[i-1]+tab[i-2];
  }
}

int inside(int n, int *tab, int c)
{
  for (int i = 0; i < c; i++)
    if (n==tab[i])
      return 1;
  return 0;
}


int main(int argc, const char *argv[])
{
  int t,n,ok, divisor;
  int fib[50];
  gen_fib(fib);

  scanf("%d", &t);
  for (int i=0; i < t; i++)
  {
    ok=0;
    scanf("%d", &n);
    for (int i = 1; i < COUNT; i++)
    {
      if (n% fib[i] == 0)
      {
        divisor = n/fib[i];
        if (inside(divisor, fib, COUNT))
        {
          ok = 1;
          break;
        }
      }
    }
    if (ok == 1)
      printf("TAK\n");
    else
      printf("NIE\n");
  }
  return 0;
}