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
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long t[10], f[50], maks;
    int i, j, k, n, nf, ok;
    ldiv_t dz;
    char odp[2][4] = {"NIE", "TAK"};

    scanf("%d", &n);
    for (maks = i = 0; i < n; i++)
    {
        scanf("%ld", &t[i]);
        if (t[i] > maks)
            maks = t[i];
    }
    f[0] = 0;
    f[1] = 1;
    for (nf = 2; f[nf - 1] < maks; nf++)
        f[nf] = f[nf - 1] + f[nf - 2];
    for (i = 0; i < n; i++)
    {
        for (ok = j = 0; !ok && j < nf; j++)
            if (t[i] == f[j])
                ok = 1;
        for (j = 2; !ok && j < nf && t[i] > f[j]; j++)
        {
            dz = ldiv(t[i], f[j]);
            if (dz.rem == 0)
                for (k = j; !ok && k < nf; k++)
                    if (dz.quot == f[k])
                        ok = 1;
        }
        printf("%s\n", odp[ok]);
    }
    return 0;
}