#include <iostream> #include <map> using namespace std; typedef long long ll; const int N = 100; map<ll, bool> prods; ll fib[N]; int main() { int how_many = 1; fib[0] = 0; fib[1] = 1; for (int i = 2; fib[i - 1] < (ll)(1e9); i++) { fib[i] = fib[i - 1] + fib[i - 2]; how_many = i; } for (int i = 0; i <= how_many; i++) { for (int j = 0; j <= how_many; j++) { prods[fib[i] * fib[j]] = true; } } int n; cin>>n; for (int i = 1; i <= n; i++) { int a; cin>>a; if (prods[a]) { cout<<"TAK\n"; } else { cout<<"NIE\n"; } } 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 <iostream> #include <map> using namespace std; typedef long long ll; const int N = 100; map<ll, bool> prods; ll fib[N]; int main() { int how_many = 1; fib[0] = 0; fib[1] = 1; for (int i = 2; fib[i - 1] < (ll)(1e9); i++) { fib[i] = fib[i - 1] + fib[i - 2]; how_many = i; } for (int i = 0; i <= how_many; i++) { for (int j = 0; j <= how_many; j++) { prods[fib[i] * fib[j]] = true; } } int n; cin>>n; for (int i = 1; i <= n; i++) { int a; cin>>a; if (prods[a]) { cout<<"TAK\n"; } else { cout<<"NIE\n"; } } return 0; } |