#include <cstdio> #include <algorithm> using namespace std; typedef unsigned long long LL; LL t[100]; const LL MX = 50; void Count() { t[0] = 1; t[1] = 1; for(LL i = 2; i < MX; ++ i) t[i] = t[i-1] + t[i-2]; } bool IsOK(LL n) { for(int i = 0; i < MX; ++ i) for(int j = i; j < MX; ++ j) if(t[i] * t[j] == n) return true; return false; } int main() { Count(); int q; scanf("%d", &q); while(q--) { LL n; scanf("%llu", &n); puts(IsOK(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 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include <cstdio> #include <algorithm> using namespace std; typedef unsigned long long LL; LL t[100]; const LL MX = 50; void Count() { t[0] = 1; t[1] = 1; for(LL i = 2; i < MX; ++ i) t[i] = t[i-1] + t[i-2]; } bool IsOK(LL n) { for(int i = 0; i < MX; ++ i) for(int j = i; j < MX; ++ j) if(t[i] * t[j] == n) return true; return false; } int main() { Count(); int q; scanf("%d", &q); while(q--) { LL n; scanf("%llu", &n); puts(IsOK(n) ? "TAK" : "NIE"); } return 0; } |