#include <cstdio>
#include <set>
using namespace std;
const int MAX = 1e9 + 5;
set<int> fib;
void licz_fib()
{
fib.insert(0);
fib.insert(1);
int f[4] = {0, 1, 0, 0};
for(int i = 2; f[(i - 1) % 4] <= MAX; i++)
{
f[i % 4] = f[(i + 2) % 4] + f[(i + 3) % 4];
fib.insert(f[i % 4]);
}
}
bool przyp()
{
int n;
scanf("%d", &n);
if(fib.find(n) != fib.end())
return true;
for(int i = 1; i * i <= n; i++)
if(n % i == 0)
if(fib.find(i) != fib.end() && fib.find(n / i) != fib.end())
return true;
return false;
}
int main()
{
licz_fib();
int t;
scanf("%d", &t);
while(t--)
printf(przyp() ? "TAK\n" : "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 34 35 36 37 38 39 40 41 42 43 | #include <cstdio> #include <set> using namespace std; const int MAX = 1e9 + 5; set<int> fib; void licz_fib() { fib.insert(0); fib.insert(1); int f[4] = {0, 1, 0, 0}; for(int i = 2; f[(i - 1) % 4] <= MAX; i++) { f[i % 4] = f[(i + 2) % 4] + f[(i + 3) % 4]; fib.insert(f[i % 4]); } } bool przyp() { int n; scanf("%d", &n); if(fib.find(n) != fib.end()) return true; for(int i = 1; i * i <= n; i++) if(n % i == 0) if(fib.find(i) != fib.end() && fib.find(n / i) != fib.end()) return true; return false; } int main() { licz_fib(); int t; scanf("%d", &t); while(t--) printf(przyp() ? "TAK\n" : "NIE\n"); return 0; } |
English