#include <cstdio> int F[44]; bool binS(int target) { int begin = -1, end = 43, middle; while (end - begin > 1) { middle = (begin + end) / 2; F[middle] < target ? begin = middle : end = middle; } return target == F[end]; } int main() { F[0] = F[1] = 1; for (int i=2; i<44; i++) F[i] = F[i - 1] + F[i - 2]; int t; scanf ("%d", &t); while (t--) { int n; scanf ("%d", &n); bool res = 0; if (n == 0) res = 1; for (int i = 1; i * i <= n; i++) { if (n % i > 0) continue; if (binS(i) and binS(n / i)) { res = 1; break; } } res ? printf("TAK\n") : 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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #include <cstdio> int F[44]; bool binS(int target) { int begin = -1, end = 43, middle; while (end - begin > 1) { middle = (begin + end) / 2; F[middle] < target ? begin = middle : end = middle; } return target == F[end]; } int main() { F[0] = F[1] = 1; for (int i=2; i<44; i++) F[i] = F[i - 1] + F[i - 2]; int t; scanf ("%d", &t); while (t--) { int n; scanf ("%d", &n); bool res = 0; if (n == 0) res = 1; for (int i = 1; i * i <= n; i++) { if (n % i > 0) continue; if (binS(i) and binS(n / i)) { res = 1; break; } } res ? printf("TAK\n") : printf("NIE\n"); } return 0; } |