#include <iostream> #include <fstream> #include <vector> #include <string> #include <algorithm> #include <stack> #include <queue> #include <set> #include <map> #include <stdlib.h> #include <time.h> using namespace std; int main(){ vector<int> fib; fib.push_back(0);fib.push_back(1); while (1){ if (fib[fib.size()-1]+fib[fib.size()-2]<=1e9){ fib.push_back(fib[fib.size()-1]+fib[fib.size()-2]); } else break; } int n; cin>>n; for (int i=0; i<n; i++){ int t,b=0; cin>>t; for (int k=0; k<fib.size()&&!b; k++){ for (int j=0; j<fib.size()&&!b; j++){ if (fib[k]*fib[j]==t){ cout<<"TAK\n"; b=1; } } } if (!b) 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 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include <iostream> #include <fstream> #include <vector> #include <string> #include <algorithm> #include <stack> #include <queue> #include <set> #include <map> #include <stdlib.h> #include <time.h> using namespace std; int main(){ vector<int> fib; fib.push_back(0);fib.push_back(1); while (1){ if (fib[fib.size()-1]+fib[fib.size()-2]<=1e9){ fib.push_back(fib[fib.size()-1]+fib[fib.size()-2]); } else break; } int n; cin>>n; for (int i=0; i<n; i++){ int t,b=0; cin>>t; for (int k=0; k<fib.size()&&!b; k++){ for (int j=0; j<fib.size()&&!b; j++){ if (fib[k]*fib[j]==t){ cout<<"TAK\n"; b=1; } } } if (!b) cout<<"NIE\n"; } } |