#include <iostream> #include <vector> #include <cstdlib> using namespace std; unsigned long long maximum(unsigned long long tab[], short t); vector<unsigned long long> fibonacci(unsigned long long n); int main() { vector<unsigned long long> fibonacciTablica; static unsigned short t, zmienna, k; unsigned long long* tablicaLiczb; unsigned long long max; cin >> t; k = 0; zmienna = t; tablicaLiczb = new unsigned long long[t]; for (int i = 0; i < t; i++) { cin >> tablicaLiczb[i]; } fibonacciTablica = fibonacci(maximum(tablicaLiczb, t)); while (zmienna != 0) { int licznik = 1; int j = 0; for (int i = 0; i <fibonacciTablica.size(); i++) { unsigned long long tymczasowa; tymczasowa = fibonacciTablica[j] * fibonacciTablica[i]; if (tymczasowa == tablicaLiczb[k]) { cout << "TAK" << endl; goto tak; } if (i >= fibonacciTablica.size() - 1) { i = 0; licznik++; j++; if (j >= fibonacciTablica.size()) { goto tu; } } } tu: cout << "NIE" << endl; tak: k++; zmienna--; } return 0; } unsigned long long maximum(unsigned long long tab[], short t) { unsigned long long max = 0; for (int i = 0; i < t; i++) { if (tab[i]> max) { max = tab[i]; } } return max; } vector<unsigned long long> fibonacci(unsigned long long n) { vector<unsigned long long> tab; unsigned long long a = 0, b = 1; tab.push_back(0); while (n >= b) { tab.push_back(b); b += a; a = b - a; } return tab; }
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #include <iostream> #include <vector> #include <cstdlib> using namespace std; unsigned long long maximum(unsigned long long tab[], short t); vector<unsigned long long> fibonacci(unsigned long long n); int main() { vector<unsigned long long> fibonacciTablica; static unsigned short t, zmienna, k; unsigned long long* tablicaLiczb; unsigned long long max; cin >> t; k = 0; zmienna = t; tablicaLiczb = new unsigned long long[t]; for (int i = 0; i < t; i++) { cin >> tablicaLiczb[i]; } fibonacciTablica = fibonacci(maximum(tablicaLiczb, t)); while (zmienna != 0) { int licznik = 1; int j = 0; for (int i = 0; i <fibonacciTablica.size(); i++) { unsigned long long tymczasowa; tymczasowa = fibonacciTablica[j] * fibonacciTablica[i]; if (tymczasowa == tablicaLiczb[k]) { cout << "TAK" << endl; goto tak; } if (i >= fibonacciTablica.size() - 1) { i = 0; licznik++; j++; if (j >= fibonacciTablica.size()) { goto tu; } } } tu: cout << "NIE" << endl; tak: k++; zmienna--; } return 0; } unsigned long long maximum(unsigned long long tab[], short t) { unsigned long long max = 0; for (int i = 0; i < t; i++) { if (tab[i]> max) { max = tab[i]; } } return max; } vector<unsigned long long> fibonacci(unsigned long long n) { vector<unsigned long long> tab; unsigned long long a = 0, b = 1; tab.push_back(0); while (n >= b) { tab.push_back(b); b += a; a = b - a; } return tab; } |