#include <cstdlib> #include <iostream> #include <string.h> #include <algorithm> #include <math.h> #include <functional> #include <set> using namespace std; int main() { long long* f = new long long [43]; //kontener na liczby fibo std::set<long long> iloczyny; //konter na iloczyny for(long long a=1,b=2,c,k=0;a<1000000000;c=a,a=b,b=b+c) { f[k++]=a; for(long long p=k-1;p>=0;p--) { iloczyny.insert(a*f[p]); } } long long t, n; cin >> t; for (long long i=0;i<t;i++) { cin >> n; if (iloczyny.find(n) != iloczyny.end()) { cout << "TAK\n"; } else { cout << "NIE\n"; } } delete f; 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 | #include <cstdlib> #include <iostream> #include <string.h> #include <algorithm> #include <math.h> #include <functional> #include <set> using namespace std; int main() { long long* f = new long long [43]; //kontener na liczby fibo std::set<long long> iloczyny; //konter na iloczyny for(long long a=1,b=2,c,k=0;a<1000000000;c=a,a=b,b=b+c) { f[k++]=a; for(long long p=k-1;p>=0;p--) { iloczyny.insert(a*f[p]); } } long long t, n; cin >> t; for (long long i=0;i<t;i++) { cin >> n; if (iloczyny.find(n) != iloczyny.end()) { cout << "TAK\n"; } else { cout << "NIE\n"; } } delete f; return 0; } |