#include <iostream> using namespace std; int main() { // Tworzenie ciagu long long int cgFib[45] = {0}; cgFib[0] = 0; cgFib[1] = 1; cgFib[2] = 1; for (int x = 3; x < 45; x++) { cgFib[x] = cgFib[x - 1] + cgFib[ x - 2]; } int n; cin>>n; for(int i = 0; i < n; i++) { int value; cin>>value; for (int x = 0; x < 46; x++) { bool loop = false; for (int y = 0; y < 45; y++) { if(x == 45) { cout<<"NIE"<<endl; loop = true; break; } if(cgFib[x] * cgFib[y] == value) { cout<<"TAK"<<endl; loop = true; break; } } if(loop == true) break; } } return 0; }
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 | #include <iostream> using namespace std; int main() { // Tworzenie ciagu long long int cgFib[45] = {0}; cgFib[0] = 0; cgFib[1] = 1; cgFib[2] = 1; for (int x = 3; x < 45; x++) { cgFib[x] = cgFib[x - 1] + cgFib[ x - 2]; } int n; cin>>n; for(int i = 0; i < n; i++) { int value; cin>>value; for (int x = 0; x < 46; x++) { bool loop = false; for (int y = 0; y < 45; y++) { if(x == 45) { cout<<"NIE"<<endl; loop = true; break; } if(cgFib[x] * cgFib[y] == value) { cout<<"TAK"<<endl; loop = true; break; } } if(loop == true) break; } } return 0; } |