/* * dawid.sieradzki@gmail.com */ #include <cstdio> #include <vector> #include <set> #include <cassert> using namespace std; vector<long long> fib; long long sum; int cnt = 2; int t; long long n; bool check(long long n) { int b = 0, e = cnt - 1; while (b <= e) { long long diff = n - fib[b] * fib[e]; if (diff == 0) { return true; } if (diff > 0) { b++; } else { e--; } } return false; } int main(int argc, char *argv[]) { fib.push_back(0); fib.push_back(1); while ((sum = fib[cnt - 2] + fib[cnt - 1]) <= 1e9) { fib.push_back(sum); cnt++; } scanf("%i", &t); while (t--) { scanf("%lli", &n); printf(check(n) ? "TAK\n" : "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 | /* * dawid.sieradzki@gmail.com */ #include <cstdio> #include <vector> #include <set> #include <cassert> using namespace std; vector<long long> fib; long long sum; int cnt = 2; int t; long long n; bool check(long long n) { int b = 0, e = cnt - 1; while (b <= e) { long long diff = n - fib[b] * fib[e]; if (diff == 0) { return true; } if (diff > 0) { b++; } else { e--; } } return false; } int main(int argc, char *argv[]) { fib.push_back(0); fib.push_back(1); while ((sum = fib[cnt - 2] + fib[cnt - 1]) <= 1e9) { fib.push_back(sum); cnt++; } scanf("%i", &t); while (t--) { scanf("%lli", &n); printf(check(n) ? "TAK\n" : "NIE\n"); } return 0; } |