#include <cstdio> int main() { int a, b, n, t, F[46] = {0,1,1}; for (int i = 3; i < 46; ++i) { F[i] = F[i - 2] + F[i - 1]; } scanf("%d", &t); while (t--) { scanf("%d", &n); a = 0; b = 45; while (a <= b) { if ((long long)F[a] * F[b] < n) ++a; else if ((long long)F[a] * F[b] > n) --b; else break; } puts((long long)F[a] * F[b] == n ? "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 | #include <cstdio> int main() { int a, b, n, t, F[46] = {0,1,1}; for (int i = 3; i < 46; ++i) { F[i] = F[i - 2] + F[i - 1]; } scanf("%d", &t); while (t--) { scanf("%d", &n); a = 0; b = 45; while (a <= b) { if ((long long)F[a] * F[b] < n) ++a; else if ((long long)F[a] * F[b] > n) --b; else break; } puts((long long)F[a] * F[b] == n ? "TAK" : "NIE"); } return 0; } |