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
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

vector<int> fib;

void odpowiedz(int x) {
    if(x == 1 || x == 0) {
        cout << "TAK" << endl;
        return ;
    }
    for(int i = 3; i < fib.size(); ++i) {
        int m = x/fib[i];
        if(binary_search (fib.begin(), fib.end(), m) && m != 0 && x % fib[i] == 0) {
            cout << "TAK"  << endl;

            return;
        }
    }
    cout << "NIE" << endl;
}

int main() {
    int n = 1000000000;
    fib.resize(2);
    fib[0] = 0;
    fib[1] =  1;
    for(int i = 1; i < n; ) {
         i = fib[fib.size()-2] + fib[fib.size()-1];
         fib.push_back(i);
    }
    int q;
    cin >> q;
    while(q--) {
        int s;
        cin >> s;
        odpowiedz(s);
    }

    return 0;
}