#include <iostream> using namespace std; typedef unsigned int uint32; #define MAX_FIBB 46 uint32 fibbLUT[MAX_FIBB]; void check(uint32 number) { for(uint32 i = 0 ; i < MAX_FIBB ; ++i) for(uint32 j = 0 ; j < MAX_FIBB ; ++j) if (fibbLUT[i] * fibbLUT[j] == number) { cout << "TAK"; return; } cout << "NIE"; } int main(int argc, char** argv) { fibbLUT[0] = 0; fibbLUT[1] = 1; for (uint32 i = 2; i < MAX_FIBB; ++i) fibbLUT[i] = fibbLUT[i - 1] + fibbLUT[i - 2]; uint32 t; cin >> t; for (uint32 i = 0; i < t; ++i) { uint32 curr; cin >> curr; check(curr); cout << "\n"; } }
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 | #include <iostream> using namespace std; typedef unsigned int uint32; #define MAX_FIBB 46 uint32 fibbLUT[MAX_FIBB]; void check(uint32 number) { for(uint32 i = 0 ; i < MAX_FIBB ; ++i) for(uint32 j = 0 ; j < MAX_FIBB ; ++j) if (fibbLUT[i] * fibbLUT[j] == number) { cout << "TAK"; return; } cout << "NIE"; } int main(int argc, char** argv) { fibbLUT[0] = 0; fibbLUT[1] = 1; for (uint32 i = 2; i < MAX_FIBB; ++i) fibbLUT[i] = fibbLUT[i - 1] + fibbLUT[i - 2]; uint32 t; cin >> t; for (uint32 i = 0; i < t; ++i) { uint32 curr; cin >> curr; check(curr); cout << "\n"; } } |