#include<cstdio> #include<iostream> #include<algorithm> #include<vector> #include<tr1/unordered_map> #include<queue> #include<cstdlib> #include<list> #include<set> #include<map> #include<cmath> #define MP make_pair #define PB push_back #define s second #define f first #define PII pair<int,int> #define VPII vector <pair<int,int> > #define VI vector <int> #define abs(a) max((a),-(a)) #define LL long long #define LD long double #define ALL(x) x.begin(),x.end() #define PU putchar_unlocked #define GU getchar_unlocked #define DBG(x) cerr<<#x<<" "<<(x)<<endl; using namespace std; int a,b,c,d,e,f,n,m,mx,l,z,r,k; int wynik; char ch; int INF=1e9+1; vector<int> fib; void pre() { fib.PB(0); fib.PB(1); while(fib.back()<INF) { fib.PB(fib[fib.size()-2]+fib.back()); } fib.pop_back(); } void solve() { scanf("%d",&n); for(int i=0;i<fib.size();i++) { for(int j=0;j<fib.size();j++) { if((LL)fib[i]*fib[j]>=INF)break; if(fib[i]*fib[j]==n) { puts("TAK"); return; } } } puts("NIE"); } main() { pre(); scanf("%d",&z); while(z--)solve(); }
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #include<cstdio> #include<iostream> #include<algorithm> #include<vector> #include<tr1/unordered_map> #include<queue> #include<cstdlib> #include<list> #include<set> #include<map> #include<cmath> #define MP make_pair #define PB push_back #define s second #define f first #define PII pair<int,int> #define VPII vector <pair<int,int> > #define VI vector <int> #define abs(a) max((a),-(a)) #define LL long long #define LD long double #define ALL(x) x.begin(),x.end() #define PU putchar_unlocked #define GU getchar_unlocked #define DBG(x) cerr<<#x<<" "<<(x)<<endl; using namespace std; int a,b,c,d,e,f,n,m,mx,l,z,r,k; int wynik; char ch; int INF=1e9+1; vector<int> fib; void pre() { fib.PB(0); fib.PB(1); while(fib.back()<INF) { fib.PB(fib[fib.size()-2]+fib.back()); } fib.pop_back(); } void solve() { scanf("%d",&n); for(int i=0;i<fib.size();i++) { for(int j=0;j<fib.size();j++) { if((LL)fib[i]*fib[j]>=INF)break; if(fib[i]*fib[j]==n) { puts("TAK"); return; } } } puts("NIE"); } main() { pre(); scanf("%d",&z); while(z--)solve(); } |