#include <iostream> #include <stdio.h> #include <vector> #include <algorithm> #include <string> #include <list> using namespace std; const int MAX = 43; const int HALF = 22; int main() { int t, n, m, i, j, found; int f[MAX+1]; f[0] = f[1] = 1; for (i=2; i<=MAX; i++) f[i] = f[i-1] + f[i-2]; cin >> t; while (t > 0) { cin >> n; t--; found = false; for (i=1; i<=HALF && !found; i++) { if (n % f[i] == 0) { m = n / f[i]; for (j=1; j<=MAX; j++) if (f[j] == m) { found = true; break; } } } cout << (found ? "TAK" : "NIE") << endl; } 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 | #include <iostream> #include <stdio.h> #include <vector> #include <algorithm> #include <string> #include <list> using namespace std; const int MAX = 43; const int HALF = 22; int main() { int t, n, m, i, j, found; int f[MAX+1]; f[0] = f[1] = 1; for (i=2; i<=MAX; i++) f[i] = f[i-1] + f[i-2]; cin >> t; while (t > 0) { cin >> n; t--; found = false; for (i=1; i<=HALF && !found; i++) { if (n % f[i] == 0) { m = n / f[i]; for (j=1; j<=MAX; j++) if (f[j] == m) { found = true; break; } } } cout << (found ? "TAK" : "NIE") << endl; } return(0); } |