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
#include <cstdio>
#include <vector>
#include <algorithm>
#define SIZE 23

std::vector<int> tablica = {1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368};
void check_fibonacci(int param)
{
    if(param == 0){printf("%s", "TAK\n");return;}
    for(int i = 0 ; i < SIZE ; ++i)
    {
        if(param % tablica[i] != 0)
            continue;
        if (std::binary_search (tablica.begin(), tablica.end(), param/tablica[i])){printf("%s", "TAK\n");return;}
    }
    printf("%s", "NIE\n");return;
}
int main(void)
{
    std::vector<int> params;
    int stop = 0, temp = 0;
    scanf("%i", &stop);
    params.reserve(stop);
    for(int i = 0 ; i < stop ; ++i)
    {
        scanf("%i", &temp);
        params.push_back(temp);
    }

    auto funkcja = std::bind(check_fibonacci, std::placeholders::_1);
    for_each(params.begin() , params.end(), funkcja);

    return 0;
}