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
#include <iostream>
#include <cmath>

using namespace std;

bool is_fibonacci(int n)
{
    int fib[2] = {0,1};
    while(fib[0]<n)
    {
        int new_fib = fib[0]+fib[1];
        fib[0] = fib[1];
        fib[1] = new_fib;
    }
    return fib[0]==n;
}

bool is_2fib_multiple(int n)
{
    if(n==0)
        return true;
    int upperbound = sqrt(n)+1;
    int fib[2] = {0,1};
    while(fib[1]<=upperbound)
    {
        if(n%fib[1]==0)
        {
            if( is_fibonacci(n/fib[1]) )
            {
                return true;
            }
        }
        int new_fib = fib[0]+fib[1];
        fib[0] = fib[1];
        fib[1] = new_fib;
    }
    return false;
}

int t;
int input[10];
int main()
{
    cin.sync_with_stdio(0);
    cin >> t;
    for(int i=0; i<t; ++i)
        cin >> input[i];

    for(int i=0; i<t; ++i)
    {
        if(is_2fib_multiple(input[i]))
            cout << "TAK";
        else
            cout << "NIE";
        if(i!=t-1)
            cout << endl;
    }
    return 0;
}