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

using namespace std;

vector <int> ciag;
long long int n,t;

bool myfunction (int i,int j) { return (i<j); }

int main(int argc, const char * argv[])
{
    ciag.push_back(0);
    ciag.push_back(1);
    cin>>t;
    for (int q=0; q<t; q++) {
        cin>>n;
        while(ciag[ciag.size()-1]<n){
            ciag.push_back(ciag[ciag.size()-1] + ciag[ciag.size()-2]);
        }
        ciag.pop_back();

    
        bool ok = false;
        for (int  i =1; !ok && ciag[i-1]<n ; i++) {
            if(n%ciag[i]==0){
                long long int x = n/ciag[i];
                if (std::binary_search (ciag.begin(), ciag.end(), x, myfunction)){
                    cout <<"TAK"<<endl;
                    ok = true;
                }
            }
        }
        if (!ok)cout<<"NIE"<<endl;
        
    }
    return 0;
}