#include <bits/stdc++.h> #define FWD(a,b,c) for(int a=(b); a<(c); ++a) typedef long long LL; using namespace std; const int N = 45; LL fib[N]; int main(){ fib[0] = 0; fib[1] = 1; FWD(i,2,N) fib[i] = fib[i-1] + fib[i-2]; int z; scanf("%d", &z); while(z--){ int n; scanf("%d", &n); bool yup = 0; FWD(i,0,N) FWD(j,i,N) if(fib[i] * fib[j] == n) yup = 1; printf(yup?"TAK\n":"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 | #include <bits/stdc++.h> #define FWD(a,b,c) for(int a=(b); a<(c); ++a) typedef long long LL; using namespace std; const int N = 45; LL fib[N]; int main(){ fib[0] = 0; fib[1] = 1; FWD(i,2,N) fib[i] = fib[i-1] + fib[i-2]; int z; scanf("%d", &z); while(z--){ int n; scanf("%d", &n); bool yup = 0; FWD(i,0,N) FWD(j,i,N) if(fib[i] * fib[j] == n) yup = 1; printf(yup?"TAK\n":"NIE\n"); } return 0; } |