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
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <iomanip>
#include <ctype.h>
#include <queue>

using namespace std;

int main()
{
    long long fib[47];
    fib[0] = 0; fib[1] = 1;

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

    int T;
    cin >> T;

    while( T-- > 0)
    {
        int n;
        cin >> n;

        bool isFact = false;

        for(int i = 1; i < 47; i++)
        {
            if(n%fib[i] == 0)
            {
                long long second = n / fib[i];
                for(int l = 1; l < 47; l++)
                    if(second == fib[l])
                        isFact = true;
            }
        }
        if(isFact || n == 0)
            cout << "TAK\n";
        else
            cout << "NIE\n";
    }

    return 0;
}