#include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { vector<int> fib; fib.push_back(1); fib.push_back(2); for(int i=1;fib[i-1]+fib[i]<1000000000;++i) fib.push_back(fib[i-1]+fib[i]); int t; cin>>t; for(int ti=0;ti<t;++ti) { int n; cin>>n; bool poss=0; if(n) { for(int i=0;i<fib.size();++i) if(!(n%fib[i]) && find(fib.begin(),fib.end(),n/fib[i])!=fib.end() ) poss=true; }else poss=true; if(poss) cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } 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 33 34 | #include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { vector<int> fib; fib.push_back(1); fib.push_back(2); for(int i=1;fib[i-1]+fib[i]<1000000000;++i) fib.push_back(fib[i-1]+fib[i]); int t; cin>>t; for(int ti=0;ti<t;++ti) { int n; cin>>n; bool poss=0; if(n) { for(int i=0;i<fib.size();++i) if(!(n%fib[i]) && find(fib.begin(),fib.end(),n/fib[i])!=fib.end() ) poss=true; }else poss=true; if(poss) cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } return 0; } |