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
54
55
56
57
58
59
60
61
#include <iostream>
using namespace std;
const int FIBSIZE = 44;
bool bs(int A[], int k)
{
    //sprawdzenie czy k jest liczba fibonacziego
    int a = 0, b = FIBSIZE-1;
    while(a <= b)
    {
        int c = (a+b)/2;
        if (A[c] == k)
            return 1;
        else
            if (A[c] > k)
                b = c-1;
            else
                a = c + 1;

    }
    if (a > b)
        return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    //44 > 1b
    int fib[FIBSIZE];
    fib[0] = 1;
    fib[1] = 1;
    for (int i = 2; i < FIBSIZE; i++)
    {
        fib[i] = fib[i-1] + fib[i-2];
    }

    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int i = 1;
        while (i * i <= n)
        {
            if (n % i == 0)
            {
                if (bs(fib, i) && bs(fib, n / i))
                    break;
            }
            i++;
        }
        if(i * i > n)
            cout<<"NIE";
        else
            cout<<"TAK";
        cout<<endl;
    }


    return 0;
}