#include <iostream> #include <vector> using namespace std; #define MAX 1000000000 vector<int> fibo; bool isFibo(int x) { for(int i = 0; i<fibo.size(); i++)if(fibo[i]==x)return true; return false; } int main() { ios_base::sync_with_stdio(false); fibo.push_back(0); fibo.push_back(1); while(fibo[fibo.size()-2]+fibo[fibo.size()-1]<=MAX)fibo.push_back(fibo[fibo.size()-2]+fibo[fibo.size()-1]); int t, n; cin >> t; while(t--) { cin >> n; bool ok = false; if(n==0) ok=true; else { for(int i=2; i<fibo.size(); i++) { if(n%fibo[i]==0 && isFibo(n/fibo[i])) { ok = true; break; } } } if(ok)cout<<"TAK\n"; else cout<<"NIE\n"; } 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include <iostream> #include <vector> using namespace std; #define MAX 1000000000 vector<int> fibo; bool isFibo(int x) { for(int i = 0; i<fibo.size(); i++)if(fibo[i]==x)return true; return false; } int main() { ios_base::sync_with_stdio(false); fibo.push_back(0); fibo.push_back(1); while(fibo[fibo.size()-2]+fibo[fibo.size()-1]<=MAX)fibo.push_back(fibo[fibo.size()-2]+fibo[fibo.size()-1]); int t, n; cin >> t; while(t--) { cin >> n; bool ok = false; if(n==0) ok=true; else { for(int i=2; i<fibo.size(); i++) { if(n%fibo[i]==0 && isFibo(n/fibo[i])) { ok = true; break; } } } if(ok)cout<<"TAK\n"; else cout<<"NIE\n"; } return 0; } |