#include <iostream> #include <time.h> #include <random> #include <vector> unsigned int fib(unsigned int n) { return 1.0 / sqrt(5.0) * (pow((1.0 + sqrt(5.0)) / 2.0, (double)(n)) - pow((1.0 - sqrt(5.0)) / 2.0, (double)(n))); } int main() { unsigned long fibo[44]; unsigned long long a; do { std::cin >> a; } while ((a<1 || a>10)); unsigned long long temp; std::vector<unsigned long long> ilosc; for (int i = 0; i < 44; ++i) { fibo[i] = fib(i); } std::vector<long long> kazdy_razy_kazdy; for (int i = 0; i < 44; ++i) { for (int j = 0; j < 44; ++j) { if (i == j) continue; temp = fibo[i] * fibo[j]; kazdy_razy_kazdy.push_back(temp); } } temp = 0; bool test = false; for (int g = 0; g < 44; ++g) { if (a == fibo[g]) { test = true; } } for (int j = 0; j < 1892; ++j) { if (a == kazdy_razy_kazdy[j]) { test = true; } } if (test == false) { std::cout << "NIE\n"; } else std::cout << "TAK\n"; EXIT_SUCCESS; }
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 | #include <iostream> #include <time.h> #include <random> #include <vector> unsigned int fib(unsigned int n) { return 1.0 / sqrt(5.0) * (pow((1.0 + sqrt(5.0)) / 2.0, (double)(n)) - pow((1.0 - sqrt(5.0)) / 2.0, (double)(n))); } int main() { unsigned long fibo[44]; unsigned long long a; do { std::cin >> a; } while ((a<1 || a>10)); unsigned long long temp; std::vector<unsigned long long> ilosc; for (int i = 0; i < 44; ++i) { fibo[i] = fib(i); } std::vector<long long> kazdy_razy_kazdy; for (int i = 0; i < 44; ++i) { for (int j = 0; j < 44; ++j) { if (i == j) continue; temp = fibo[i] * fibo[j]; kazdy_razy_kazdy.push_back(temp); } } temp = 0; bool test = false; for (int g = 0; g < 44; ++g) { if (a == fibo[g]) { test = true; } } for (int j = 0; j < 1892; ++j) { if (a == kazdy_razy_kazdy[j]) { test = true; } } if (test == false) { std::cout << "NIE\n"; } else std::cout << "TAK\n"; EXIT_SUCCESS; } |