#include<iostream> using namespace std; int main(){ int t, x,n=2; cin>>t; long long FIBO[1000]; FIBO[0]=1; FIBO[1]=1; for(int i=1;i<=1000;i++) FIBO[i]=FIBO[i-2]+FIBO[i-1]; for(int i=0;i<t;i++){ cin>>x; while(FIBO[n+1]<=x){ n++; } for(int l=0;l<2;l++){ while(x%FIBO[n]!=0)n--; if(n>1){x=x/FIBO[n];while(FIBO[n]!=x &&n!=1)n--;} else break; } if(x==1)cout<<"TAK"<<endl; else cout<<"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 | #include<iostream> using namespace std; int main(){ int t, x,n=2; cin>>t; long long FIBO[1000]; FIBO[0]=1; FIBO[1]=1; for(int i=1;i<=1000;i++) FIBO[i]=FIBO[i-2]+FIBO[i-1]; for(int i=0;i<t;i++){ cin>>x; while(FIBO[n+1]<=x){ n++; } for(int l=0;l<2;l++){ while(x%FIBO[n]!=0)n--; if(n>1){x=x/FIBO[n];while(FIBO[n]!=x &&n!=1)n--;} else break; } if(x==1)cout<<"TAK"<<endl; else cout<<"NIE"; } return 0; } |