#include <cstdio> int main() { int f[50] = { 0, 1 }, fn = 1; for (int i = 1; f[i] <= 1000000000; i++, f[i] = f[i-1] + f[i-2]) { fn++; } int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); bool fib = false; if (n < 4) { fib = true; } else { for (int i = 3; i < fn && f[i] <= n; i++) { if (n % f[i] == 0) { int div = n / f[i]; for (int j = 2; j < fn; j++) { if (f[j] == div) { fib = true; } } } } } fib ? printf("TAK\n") : printf("NIE\n"); } }
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> int main() { int f[50] = { 0, 1 }, fn = 1; for (int i = 1; f[i] <= 1000000000; i++, f[i] = f[i-1] + f[i-2]) { fn++; } int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); bool fib = false; if (n < 4) { fib = true; } else { for (int i = 3; i < fn && f[i] <= n; i++) { if (n % f[i] == 0) { int div = n / f[i]; for (int j = 2; j < fn; j++) { if (f[j] == div) { fib = true; } } } } } fib ? printf("TAK\n") : printf("NIE\n"); } } |