#include <cstdio> #include <set> using namespace std; #define REP(i,n) for (int i = 0; i < (n); ++i) #define VAR(v,w) __typeof(w) v = (w) #define FORE(it,c) for (VAR(it,(c).begin()); it != (c).end(); ++it) typedef long long LL; int main() { LL a = 0, b = 1; set<int> f; while (b <= 1000000000) { f.insert(b); LL c = a; a = b; b += c; } int t; scanf("%d", &t); REP(tt,t) { int n; scanf("%d", &n); if (!n) { printf("TAK\n"); continue; } bool ok = 0; FORE(it,f) if (!(n % *it) && f.find(n / *it) != f.end()) { ok = 1; break; } printf(ok ? "TAK\n" : "NIE\n"); } }
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 | #include <cstdio> #include <set> using namespace std; #define REP(i,n) for (int i = 0; i < (n); ++i) #define VAR(v,w) __typeof(w) v = (w) #define FORE(it,c) for (VAR(it,(c).begin()); it != (c).end(); ++it) typedef long long LL; int main() { LL a = 0, b = 1; set<int> f; while (b <= 1000000000) { f.insert(b); LL c = a; a = b; b += c; } int t; scanf("%d", &t); REP(tt,t) { int n; scanf("%d", &n); if (!n) { printf("TAK\n"); continue; } bool ok = 0; FORE(it,f) if (!(n % *it) && f.find(n / *it) != f.end()) { ok = 1; break; } printf(ok ? "TAK\n" : "NIE\n"); } } |