#include <cstdio>
long fibs[46];
bool isProduct(long n)
{
for(int i = 0; i < 46; i++)
{
for(int j = i; j < 46; j++)
{
if(fibs[i]*fibs[j] == n)
return true;
}
}
return false;
}
int main(void)
{
int t;
scanf("%d",&t);
long n;
fibs[0] = 0;
fibs[1] = 1;
int index = 1;
while(fibs[index] <= 1000000000)
{
index++;
fibs[index] = fibs[index - 1] + fibs[index - 2];
}
for(int i = 0; i < t; i++)
{
scanf("%ld",&n);
printf("%s",isProduct(n) ? "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 | #include <cstdio> long fibs[46]; bool isProduct(long n) { for(int i = 0; i < 46; i++) { for(int j = i; j < 46; j++) { if(fibs[i]*fibs[j] == n) return true; } } return false; } int main(void) { int t; scanf("%d",&t); long n; fibs[0] = 0; fibs[1] = 1; int index = 1; while(fibs[index] <= 1000000000) { index++; fibs[index] = fibs[index - 1] + fibs[index - 2]; } for(int i = 0; i < t; i++) { scanf("%ld",&n); printf("%s",isProduct(n) ? "TAK\n" : "NIE\n"); } return 0; } |
English