#include <cstdio> using namespace std; const int N = 100, OGR = 1E9; int fib[100], lif, zap; void gen_fib() { fib[0] = 0, fib[1] = 1; for (lif = 2; fib[lif-1] <= OGR; lif++) fib[lif] = fib[lif-1]+fib[lif-2]; lif--; } void zapytania() { int zap, a; bool war; scanf("%d", &zap); while (zap--) { scanf("%d", &a); war = 0; for (int i = 0; i < lif && war == 0; i++) for (int j = i; j < lif && war == 0; j++) if ((long long)fib[i]*fib[j] == a) war = 1; if (war == 1) printf("TAK\n"); else printf("NIE\n"); } } int main() { gen_fib(); zapytania(); 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 | #include <cstdio> using namespace std; const int N = 100, OGR = 1E9; int fib[100], lif, zap; void gen_fib() { fib[0] = 0, fib[1] = 1; for (lif = 2; fib[lif-1] <= OGR; lif++) fib[lif] = fib[lif-1]+fib[lif-2]; lif--; } void zapytania() { int zap, a; bool war; scanf("%d", &zap); while (zap--) { scanf("%d", &a); war = 0; for (int i = 0; i < lif && war == 0; i++) for (int j = i; j < lif && war == 0; j++) if ((long long)fib[i]*fib[j] == a) war = 1; if (war == 1) printf("TAK\n"); else printf("NIE\n"); } } int main() { gen_fib(); zapytania(); return 0; } |