#include <iostream> #include <cstdio> #include <set> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int f[50]={0,1},t,n; set<int> s; set<int>::iterator it; int main(int argc, char** argv) { for(int i=2;i<45;i++) { f[i]=f[i-1]+f[i-2]; for (int j=0;j<=i;j++) { long long k = (long long)f[i]*f[j]; if (k<0) break; if (k<=1000000000) s.insert((int)k); } } //for (it=s.begin();it!=s.end();it++) printf("%d,",*it); printf("%d",s.size()); scanf("%d",&t); while (t--) { scanf("%d",&n); if (s.find(n)==s.end()) printf("NIE\n"); else printf("TAK\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 | #include <iostream> #include <cstdio> #include <set> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int f[50]={0,1},t,n; set<int> s; set<int>::iterator it; int main(int argc, char** argv) { for(int i=2;i<45;i++) { f[i]=f[i-1]+f[i-2]; for (int j=0;j<=i;j++) { long long k = (long long)f[i]*f[j]; if (k<0) break; if (k<=1000000000) s.insert((int)k); } } //for (it=s.begin();it!=s.end();it++) printf("%d,",*it); printf("%d",s.size()); scanf("%d",&t); while (t--) { scanf("%d",&n); if (s.find(n)==s.end()) printf("NIE\n"); else printf("TAK\n"); } return 0; } |