#include <iostream> #include <vector> using namespace std; vector<long long> fs(41, -1); int main() { fs[0] = 0; fs[1] = 1; for (int i = 2; i <= 40; ++i) fs[i] = fs[i-1]+fs[i-2]; int T; cin >> T; while (T--) { int N; cin >> N; bool solved = false; bool eq = false; for (int i = 0; i < fs.size(); ++i) { if (solved) break; for (int k = 0; k < fs.size(); ++k) if (fs[i]*fs[k] == N) { eq = true; solved = true; break; } } cout << (eq ? "TAK" : "NIE") << endl; } }
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 | #include <iostream> #include <vector> using namespace std; vector<long long> fs(41, -1); int main() { fs[0] = 0; fs[1] = 1; for (int i = 2; i <= 40; ++i) fs[i] = fs[i-1]+fs[i-2]; int T; cin >> T; while (T--) { int N; cin >> N; bool solved = false; bool eq = false; for (int i = 0; i < fs.size(); ++i) { if (solved) break; for (int k = 0; k < fs.size(); ++k) if (fs[i]*fs[k] == N) { eq = true; solved = true; break; } } cout << (eq ? "TAK" : "NIE") << endl; } } |