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

using namespace std;

int fib[ 47 + 1 ];

void generuj()
{
     fib[ 0 ] = 0;
     fib[ 1 ] = 1;

     for( int i = 2 ; i < 47 ; ++i )
        fib[ i ] = fib[ i - 1 ] + fib[ i - 2 ];
} //generuj

bool fibonacci( int n )
{
     long long w = 0;

     for( int i = 0 ; i < 47 ; ++i )
     {
        if( fib[ i ] <= n )
        {
            for( int j = 0 ; j < 47 ; ++j )
            {
                w = fib[ i ] * fib[ j ];
                if( w == n )
                    return true;
                else if( fib[ j ] > n )
                    break;
            }
        }
     }
     return false;
} //fibonacci

int main()
{   
    ios_base::sync_with_stdio( 0 );

    int t, n;
    cin >> t;

    generuj();

    while( t-- )
    {
        cin >> n;

        if( fibonacci( n ) == true )
            cout << "TAK" << endl;
        else
            cout << "NIE" << endl;
    }
    return 0;
} //main