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 <iostream>
#include <vector>
using namespace std;

vector< int >tab;
bool result = false;

void fib(int n){
    tab.push_back(1);
    int x = 1;
    int y = 1;
    int c = 0;
    while(true){
        c = x;
        tab.push_back(x);
        x += y;
        if(x > n) break;
        y = c;
    }
}

void clear(){
    tab.clear();
    result = false;
}

int main(){
    int t, a;
    cin >> t;
    while(t --){
        cin >> a;
        fib(a);
        int d = tab.size();
        for(int i = 0; i < d; i++){
            for(int j = i; j < d; j++){
                if(tab[i] * tab[j] == a){
                    result = true;
                    break;
                }
                else if(tab[i] * tab[j] > a) break;
            }
            if(result == true) break;
        }
        if(result == true) cout << "TAK" << endl;
        else cout << "NIE" << endl;
        clear();
    }
    return 0;
}