#include <fstream> #include <iostream> using namespace std; int main(){ int fib[44]; int a,b,c,i=0; a=b=c=1; // cout<<a<<endl<<b; while(i<44) {c=a+b; a=b;b=c; fib[i]=a; i++; } int t,x,dod; bool bw; cin>>t; for(;t>0;t--) {cin>>x; if(x==0)cout<<"TAK";else{ bw=false; for(i=0;i<=43;i++) { if(x%fib[i]==0) {dod=x/fib[i]; for(int i2=0;i2<=43;i2++) {if (dod==fib[i2])bw=true;} } } if (bw)cout<<"TAK"<<endl;else cout<<"NIE"<<endl; }} //cout<<fib[0]; //system("Pause"); }
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 | #include <fstream> #include <iostream> using namespace std; int main(){ int fib[44]; int a,b,c,i=0; a=b=c=1; // cout<<a<<endl<<b; while(i<44) {c=a+b; a=b;b=c; fib[i]=a; i++; } int t,x,dod; bool bw; cin>>t; for(;t>0;t--) {cin>>x; if(x==0)cout<<"TAK";else{ bw=false; for(i=0;i<=43;i++) { if(x%fib[i]==0) {dod=x/fib[i]; for(int i2=0;i2<=43;i2++) {if (dod==fib[i2])bw=true;} } } if (bw)cout<<"TAK"<<endl;else cout<<"NIE"<<endl; }} //cout<<fib[0]; //system("Pause"); } |