#include <cstdio> using namespace std; typedef long long LL; const int MX = 1e9; LL F[100] = {0, 1}, S = 2; int main() { while (F[S-1] <= MX) F[S] = F[S-1] + F[S-2], ++S; int q; scanf("%d", &q); while (q--) { int x, a = 0, b = S-1; scanf("%d", &x); bool ok = false; while (a <= b) { if (F[a]*F[b] < x) ++a; else if (F[a]*F[b] > x) --b; else { ok = true; break; } } puts(ok ? "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 33 | #include <cstdio> using namespace std; typedef long long LL; const int MX = 1e9; LL F[100] = {0, 1}, S = 2; int main() { while (F[S-1] <= MX) F[S] = F[S-1] + F[S-2], ++S; int q; scanf("%d", &q); while (q--) { int x, a = 0, b = S-1; scanf("%d", &x); bool ok = false; while (a <= b) { if (F[a]*F[b] < x) ++a; else if (F[a]*F[b] > x) --b; else { ok = true; break; } } puts(ok ? "TAK" : "NIE"); } return 0; } |