#include <stdio.h> const int LIMIT = 100*1000; int main(){ int t, i, j, k, a, fib[1000]; fib[0] = 0; fib[1] = 1; i = 1; while (fib[i++] < LIMIT) { fib[i] = fib[i-1] + fib[i-2]; } int n = i-1; scanf("%d", &t); for (i = 0; i < t; ++i) { scanf("%d", &a); int found = 0; for (j = 0; j < n; ++j) { for (k = 0; k < n; ++k) { if (fib[j] * fib[k] == a) { found = 1; } } } if (found) { 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 <stdio.h> const int LIMIT = 100*1000; int main(){ int t, i, j, k, a, fib[1000]; fib[0] = 0; fib[1] = 1; i = 1; while (fib[i++] < LIMIT) { fib[i] = fib[i-1] + fib[i-2]; } int n = i-1; scanf("%d", &t); for (i = 0; i < t; ++i) { scanf("%d", &a); int found = 0; for (j = 0; j < n; ++j) { for (k = 0; k < n; ++k) { if (fib[j] * fib[k] == a) { found = 1; } } } if (found) { printf("TAK\n"); } else { printf("NIE\n"); } } return 0; } |