#include <cstdio> #include <vector> using namespace std; const long long MAXN = 1e9; vector<long long> fib; void getFib() { fib.push_back(0); fib.push_back(1); while(fib.back() < MAXN) fib.push_back(fib.back() + fib[fib.size() - 2]); } bool isProduct(long long n) { for(auto i : fib) for(auto j : fib) if(i * j == n) return true; return false; } int main() { getFib(); int t; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); if(isProduct(n)) printf("TAK\n"); else printf("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 37 38 39 40 41 | #include <cstdio> #include <vector> using namespace std; const long long MAXN = 1e9; vector<long long> fib; void getFib() { fib.push_back(0); fib.push_back(1); while(fib.back() < MAXN) fib.push_back(fib.back() + fib[fib.size() - 2]); } bool isProduct(long long n) { for(auto i : fib) for(auto j : fib) if(i * j == n) return true; return false; } int main() { getFib(); int t; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); if(isProduct(n)) printf("TAK\n"); else printf("NIE\n"); } return 0; } |