#include <cstdio> #define LL long long LL fib[50]; int main() { fib[0] = 0; fib[1] = 1; int n = 2; while (fib[n - 1] + fib[n - 2] <= 1000000000) { fib[n] = fib[n - 1] + fib[n - 2]; n++; } int test; scanf("%d", &test); while (test--) { LL num; scanf("%lld", &num); bool succ = false; for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { if (fib[i] * fib[j] == num) { succ = true; } } } if (succ) { 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 | #include <cstdio> #define LL long long LL fib[50]; int main() { fib[0] = 0; fib[1] = 1; int n = 2; while (fib[n - 1] + fib[n - 2] <= 1000000000) { fib[n] = fib[n - 1] + fib[n - 2]; n++; } int test; scanf("%d", &test); while (test--) { LL num; scanf("%lld", &num); bool succ = false; for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { if (fib[i] * fib[j] == num) { succ = true; } } } if (succ) { printf("TAK\n"); } else { printf("NIE\n"); } } return 0; } |