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

typedef long long ll;

static const ll maxN = 1e9;

int main() {
    ll fib[50];
    int maxIx = 0;
    fib[maxIx] = 0;
    fib[++maxIx] = 1;
    while (fib[maxIx] <= maxN) {
        ++maxIx;
        fib[maxIx] = fib[maxIx - 1] + fib[maxIx - 2];
    }
    
    long t;
    scanf("%ld", &t);
    
    for (ll i = 0; i < t; ++i) {
        long n;
        scanf("%ld", &n);
        
        bool fibfib = n == 0;
        for (ll a = 1; a <= maxIx; ++a) {            
            for (ll b = 1; b <= maxIx; ++b) {
                ll fafb = fib[a] * fib[b];
                if (fafb == n) {
                    fibfib = true;
                    break;
                } else if (fafb > n) {
                    break;
                }
            }
            
            if (fibfib) {
                break;
            }
        }
        
        if (fibfib) {
            printf("TAK\n");
        } else {
            printf("NIE\n");
        }
    }
    
    return 0;
}