#include<cstdio> int t1[50]; void fib() { t1[0] = 0; t1[1] = 1; for (int i = 2; i <= 44; i++) t1[i] = t1[i-1] + t1[i - 2]; } bool check(int n) { for (int i = 0; i < 45; i++) for (int j = 0; j < 45; j++) { if (t1[i] * t1[j] == n) return 1; } return 0; } int main() { fib(); // generowanie tablicy int t; scanf("%d", &t); for (int i = 0; i < t; i++) { int n; scanf("%d", &n); if (check(n)) puts("TAK"); else puts("NIE"); } 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 | #include<cstdio> int t1[50]; void fib() { t1[0] = 0; t1[1] = 1; for (int i = 2; i <= 44; i++) t1[i] = t1[i-1] + t1[i - 2]; } bool check(int n) { for (int i = 0; i < 45; i++) for (int j = 0; j < 45; j++) { if (t1[i] * t1[j] == n) return 1; } return 0; } int main() { fib(); // generowanie tablicy int t; scanf("%d", &t); for (int i = 0; i < t; i++) { int n; scanf("%d", &n); if (check(n)) puts("TAK"); else puts("NIE"); } return 0; } |