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
50
51
52
53
#include <iostream>
#include <array>
#include <vector>
#define fiblen 45

using namespace std;

array<unsigned long, fiblen> make_fib()
{
    array<unsigned long, fiblen> ret;
    ret[0] = 0;
    ret[1] = 1;
    for(int i = 2; i<fiblen; i++)
        ret[i]=ret[i-1]+ret[i-2];
    return ret;
}

bool checkFib(unsigned long n,array<unsigned long, fiblen>& fib)
{
    for(int i=1; i<fiblen;i++)
        if(n%fib[i]==0)
        for(int j=i;j<fiblen;j++)
        {
            if(n/fib[i]==fib[j])
            return true;
        }
    return false;
}

int main()
{
    int t, ni;

    array<unsigned long, fiblen> fib = make_fib();
    vector<int> n;
    cin>>t;

    for(int i=0;i<t;i++)
    {
        cin>>ni;
        n.push_back(ni);
    }

    for(int i=0;i<t;i++)
    {
            switch(checkFib(n[i],fib))
            {
                case true: cout<<"TAK"<<endl; break;
                case false: cout<<"NIE"<<endl; break;
            }
    }
    return 0;
}