#include <cstdio> #include <vector> #include <set> std::vector<int> fib; std::set<long long> multi; void preproc() { fib.push_back(0); fib.push_back(1); while (fib[fib.size() - 1] < 1e9) { int size = fib.size(); fib.push_back(fib[size - 1] + fib[size - 2]); } int count = fib.size(); for (int i = 0; i < count; ++i) for (int j = 0; j <= i; ++j) multi.insert((long long)fib[i] * fib[j]); } void processCase() { int t; scanf("%d", &t); printf(multi.count(t) ? "TAK\n" : "NIE\n"); } int main() { preproc(); int n; scanf("%d", &n); while(n--) processCase(); 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 | #include <cstdio> #include <vector> #include <set> std::vector<int> fib; std::set<long long> multi; void preproc() { fib.push_back(0); fib.push_back(1); while (fib[fib.size() - 1] < 1e9) { int size = fib.size(); fib.push_back(fib[size - 1] + fib[size - 2]); } int count = fib.size(); for (int i = 0; i < count; ++i) for (int j = 0; j <= i; ++j) multi.insert((long long)fib[i] * fib[j]); } void processCase() { int t; scanf("%d", &t); printf(multi.count(t) ? "TAK\n" : "NIE\n"); } int main() { preproc(); int n; scanf("%d", &n); while(n--) processCase(); return 0; } |