#include <iostream> #include <vector> #include <unordered_set> #include <algorithm> int main() { std::unordered_set<unsigned long long> ufib(45); std::vector<unsigned long long> ofib(44); ufib.insert(0); unsigned long long a = 0, b = 1, c, idx = 0; while (idx < 44) { ufib.insert(a + b); ofib[idx++] = a + b; c = b; b = a + c; a = c; } int t; std::cin >> t; while (t-- > 0) { idx = 0; bool pos = false; unsigned long long n, e = ofib[idx++]; std::cin >> n; while (idx < 44) { auto it = ufib.find(n / e); if (it != ufib.end() && e * (*it) == n) { pos = true; break; } e = ofib[idx++]; } std::cout << (pos ? "TAK\n" : "NIE\n"); } 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 | #include <iostream> #include <vector> #include <unordered_set> #include <algorithm> int main() { std::unordered_set<unsigned long long> ufib(45); std::vector<unsigned long long> ofib(44); ufib.insert(0); unsigned long long a = 0, b = 1, c, idx = 0; while (idx < 44) { ufib.insert(a + b); ofib[idx++] = a + b; c = b; b = a + c; a = c; } int t; std::cin >> t; while (t-- > 0) { idx = 0; bool pos = false; unsigned long long n, e = ofib[idx++]; std::cin >> n; while (idx < 44) { auto it = ufib.find(n / e); if (it != ufib.end() && e * (*it) == n) { pos = true; break; } e = ofib[idx++]; } std::cout << (pos ? "TAK\n" : "NIE\n"); } return 0; } |