#include<cstdio> #include<vector> int main() { std::vector<int> fibs; fibs.push_back(1); fibs.push_back(1); while (fibs.back() < (1<<30)) fibs.push_back(fibs.back() + fibs[fibs.size()-2]); int t; scanf("%d", &t); while (t--) { int x; scanf("%d", &x); int found = false; for (int i=0; i<fibs.size() && !found; i++) for (int j=0; j<fibs.size() && !found; j++) found = fibs[i] * fibs[j] == x; printf("%s\n", found ? "TAK" : "NIE"); } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include<cstdio> #include<vector> int main() { std::vector<int> fibs; fibs.push_back(1); fibs.push_back(1); while (fibs.back() < (1<<30)) fibs.push_back(fibs.back() + fibs[fibs.size()-2]); int t; scanf("%d", &t); while (t--) { int x; scanf("%d", &x); int found = false; for (int i=0; i<fibs.size() && !found; i++) for (int j=0; j<fibs.size() && !found; j++) found = fibs[i] * fibs[j] == x; printf("%s\n", found ? "TAK" : "NIE"); } return 0; } |