#include <cstdio> #include <map> #include <algorithm> using namespace std; map <long long int, long long int> tab; const int GUARD = 1000000000; const int MAXN = 3007; long long int fib[MAXN], numbers[MAXN]; int i = 1; int main() { fib[1] = 1; while (fib[i] < GUARD) { fib[i + 1] = fib[i] + fib[i - 1]; ++i; } for (int j = 0; j <= i; ++j) { for (int k = j; k <= i; ++k) { tab[fib[j] * fib[k]] = 1; } } int t; scanf("%d", &t); for (int j = 0; j < t; ++j) { int lb; scanf("%d", &lb); if (tab.find(lb) == tab.end()) { printf("NIE\n"); } else { printf("TAK\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 | #include <cstdio> #include <map> #include <algorithm> using namespace std; map <long long int, long long int> tab; const int GUARD = 1000000000; const int MAXN = 3007; long long int fib[MAXN], numbers[MAXN]; int i = 1; int main() { fib[1] = 1; while (fib[i] < GUARD) { fib[i + 1] = fib[i] + fib[i - 1]; ++i; } for (int j = 0; j <= i; ++j) { for (int k = j; k <= i; ++k) { tab[fib[j] * fib[k]] = 1; } } int t; scanf("%d", &t); for (int j = 0; j < t; ++j) { int lb; scanf("%d", &lb); if (tab.find(lb) == tab.end()) { printf("NIE\n"); } else { printf("TAK\n"); } } return 0; } |