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

using namespace std;


int fibNrs[10000];
map<int, bool> fibMap;


bool isFibNr(int a) {
    int curr = 1;
    for (int i = 1; curr < a; ++i) {
        if (a%curr == 0 && fibMap.find(a/curr)->second) {
            return true;
        }
        curr = fibNrs[i];
    }
    return false;
}

int main() {
    int n, a;
    scanf("%d", &n);

    int tmp;
    int curr1 = 1, curr2 = 1;
    fibNrs[0] = curr1;
    for(int i = 1; curr2 < 1000000000; ++i) {
        fibMap[curr2] = true;
        fibNrs[i] = curr2;

        tmp = curr2;
        curr2 += curr1;
        curr1 = tmp;
    }

    for (int i = 0; i < n; ++i) {
        scanf("%d", &a);

        isFibNr(a) ? printf("TAK\n") : printf("NIE\n");
    }

    return 0;
}