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
#include <cstdio>
#include <algorithm>
#define scanf(args...) (scanf(args) ? : 0)
typedef long long int LL;
const int FIBCOUNT = 46;
const int MAXR = 1000000;
const int INF = 1e9;

int fib[FIBCOUNT], res[MAXR];

int main() {
    fib[0] = 0;
    fib[1] = 1;
    for (int i=2; i<FIBCOUNT; i++)
        fib[i] = fib[i-1]+fib[i-2];

    int size = 0;
    for (int i=0; i<FIBCOUNT; i++)
        for (int j=i; j<FIBCOUNT && (LL)fib[i]*fib[j] <= INF; j++)
            res[size++] = fib[i]*fib[j];
    std::sort(res, res+size);

    int t;
    scanf("%d", &t);

    while (t--) {
        int n;
        scanf("%d", &n);

        if (std::binary_search(res, res+size, n))
            printf("TAK\n");
        else
            printf("NIE\n");
    }
}