#include <iostream> #include <cstdio> #include <vector> using namespace std; vector <long long> tab; int main() { int n; long long a, b, c, x; bool czy = false; a = b = 1; c = 2; tab.push_back(0); tab.push_back(1); tab.push_back(1); while(c < 1000000000) { c = a + b; a = b; b = c; tab.push_back(c); } scanf("%d", &n); for(int i2 = 0; i2 < n; i2++) { scanf("%lld", &x); czy = false; for(int i = 0; i < tab.size(); i++) { for(int j = 0; j < tab.size(); j++) { if(tab[i] * tab[j] == x) { czy = true; break; } } if(czy) break; } if(czy) printf("TAK\n"); else printf("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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #include <iostream> #include <cstdio> #include <vector> using namespace std; vector <long long> tab; int main() { int n; long long a, b, c, x; bool czy = false; a = b = 1; c = 2; tab.push_back(0); tab.push_back(1); tab.push_back(1); while(c < 1000000000) { c = a + b; a = b; b = c; tab.push_back(c); } scanf("%d", &n); for(int i2 = 0; i2 < n; i2++) { scanf("%lld", &x); czy = false; for(int i = 0; i < tab.size(); i++) { for(int j = 0; j < tab.size(); j++) { if(tab[i] * tab[j] == x) { czy = true; break; } } if(czy) break; } if(czy) printf("TAK\n"); else printf("NIE\n"); } return 0; } |