#include <iostream> using namespace std; long long fibo[1000000], a, f, t; void jebaj() { for(int i = 0; i < f; ++i) for(int j = 0; j < f; ++j) if(fibo[i] * fibo[j] == a) { cout << "TAK\n"; return; } cout << "NIE\n"; } int main() { fibo[0] = 1; fibo[1] = 1; for(f = 2; fibo[f - 1] + fibo[f - 2] < 1000000009; ++f) fibo[f] = fibo[f - 1] + fibo[f - 2]; cin >> t; for(int tt; tt < t; ++tt) { cin >> a; jebaj(); } 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 | #include <iostream> using namespace std; long long fibo[1000000], a, f, t; void jebaj() { for(int i = 0; i < f; ++i) for(int j = 0; j < f; ++j) if(fibo[i] * fibo[j] == a) { cout << "TAK\n"; return; } cout << "NIE\n"; } int main() { fibo[0] = 1; fibo[1] = 1; for(f = 2; fibo[f - 1] + fibo[f - 2] < 1000000009; ++f) fibo[f] = fibo[f - 1] + fibo[f - 2]; cin >> t; for(int tt; tt < t; ++tt) { cin >> a; jebaj(); } return 0; } |