#include<iostream> using namespace std; long long fib[100],a; int n; main(){ n=2; fib[0]=0; fib[1]=1; while(1){ if(fib[n-2]+fib[n-1]>1000000000)break; n++; fib[n-1]=fib[n-2]+fib[n-3]; } int t; cin>>t; for(int i=0;i<t;i++){ bool ok=0; cin>>a; for(int j=0;j<n;j++){ for(int k=0;k<n;k++){ if(fib[j]*fib[k]==a)ok=1; } } if(ok)cout<<"TAK\n"; else cout<<"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 | #include<iostream> using namespace std; long long fib[100],a; int n; main(){ n=2; fib[0]=0; fib[1]=1; while(1){ if(fib[n-2]+fib[n-1]>1000000000)break; n++; fib[n-1]=fib[n-2]+fib[n-3]; } int t; cin>>t; for(int i=0;i<t;i++){ bool ok=0; cin>>a; for(int j=0;j<n;j++){ for(int k=0;k<n;k++){ if(fib[j]*fib[k]==a)ok=1; } } if(ok)cout<<"TAK\n"; else cout<<"NIE\n"; } } |