#include <cstdio> #include <set> #include <vector> using namespace std; int main() { int i,j,n; vector<int> F; set<int> FF; F.push_back(0); F.push_back(1); do { i = F[F.size()-2]+F[F.size()-1]; F.push_back(i); } while (F[F.size()-1] < 1000000000); for (i = 0; i < F.size(); i++) for (j = 0; j < F.size(); j++) if ((double) F[i] * (double) F[j] <= 1000000000.0) FF.insert(F[i]*F[j]); scanf("%d",&n); for (i = 0; i < n; i++) { scanf("%d",&j); if (FF.find(j) == FF.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 31 | #include <cstdio> #include <set> #include <vector> using namespace std; int main() { int i,j,n; vector<int> F; set<int> FF; F.push_back(0); F.push_back(1); do { i = F[F.size()-2]+F[F.size()-1]; F.push_back(i); } while (F[F.size()-1] < 1000000000); for (i = 0; i < F.size(); i++) for (j = 0; j < F.size(); j++) if ((double) F[i] * (double) F[j] <= 1000000000.0) FF.insert(F[i]*F[j]); scanf("%d",&n); for (i = 0; i < n; i++) { scanf("%d",&j); if (FF.find(j) == FF.end()) printf("NIE\n"); else printf("TAK\n"); } return 0; } |