#include <cstdio> typedef long long ll; #define MAXN 1000000000 bool Check(ll f[], ll n){ int p=0, q=43; while(p<=q){ ll tmp=f[p]*f[q]; if(tmp==n) return true; if(n>tmp) ++p; else --q; } return false; } int main() { ll f[50]={0,1,2}; for(int i=3;i<=43;++i) f[i]=f[i-1]+f[i-2]; int t, n; scanf("%d", &t); while(t--){ scanf("%d", &n); if(Check(f, n)) printf("TAK\n"); else printf("NIE\n"); } }
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 | #include <cstdio> typedef long long ll; #define MAXN 1000000000 bool Check(ll f[], ll n){ int p=0, q=43; while(p<=q){ ll tmp=f[p]*f[q]; if(tmp==n) return true; if(n>tmp) ++p; else --q; } return false; } int main() { ll f[50]={0,1,2}; for(int i=3;i<=43;++i) f[i]=f[i-1]+f[i-2]; int t, n; scanf("%d", &t); while(t--){ scanf("%d", &n); if(Check(f, n)) printf("TAK\n"); else printf("NIE\n"); } } |