#include <cstdio> using namespace std; int main() { unsigned long long fibs[50]; fibs[0] = 0; fibs[1] = 1; int c = 1; while (fibs[c] < 1000000000) { c++; fibs[c] = fibs[c-1] + fibs[c-2]; } int d; scanf("%d", &d); while(d--) { int n; scanf("%d", &n); bool can = false; for (int j = 0; j < c; j++) { for (int k = 0; k < c; k++) { if (fibs[j] * fibs[k] == n) { can = true; break; } } } printf("%s\n", can ? "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 23 24 25 26 27 28 29 30 31 32 | #include <cstdio> using namespace std; int main() { unsigned long long fibs[50]; fibs[0] = 0; fibs[1] = 1; int c = 1; while (fibs[c] < 1000000000) { c++; fibs[c] = fibs[c-1] + fibs[c-2]; } int d; scanf("%d", &d); while(d--) { int n; scanf("%d", &n); bool can = false; for (int j = 0; j < c; j++) { for (int k = 0; k < c; k++) { if (fibs[j] * fibs[k] == n) { can = true; break; } } } printf("%s\n", can ? "TAK" : "NIE"); } return 0; } |