#include <cstdio>
#include <memory.h>
using namespace std;
int F[100];
bool B[100];
int main()
{
int tt;
scanf("%d",&tt);
int num_f=2;
F[0]=1; F[1]=2;
while ( ( F[num_f] = F[num_f-1]+F[num_f-2] ) < 1e9 )
num_f++;
while ( tt-- )
{
memset( B, '\0', num_f*sizeof(bool) );
int n;
scanf( "%d",&n );
if ( !n ) { printf("TAK\n"); goto kon; }
for ( int i=0; i<num_f; i++ ) if ( !(n%F[i]) )
{
int c = n/F[i];
int d = num_f-1;
while ( d && F[d]!=c ) d--;
if ( F[d]==c )
{
printf("TAK\n");
goto kon;
}
}
printf("NIE\n");
kon:;
}
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 <cstdio> #include <memory.h> using namespace std; int F[100]; bool B[100]; int main() { int tt; scanf("%d",&tt); int num_f=2; F[0]=1; F[1]=2; while ( ( F[num_f] = F[num_f-1]+F[num_f-2] ) < 1e9 ) num_f++; while ( tt-- ) { memset( B, '\0', num_f*sizeof(bool) ); int n; scanf( "%d",&n ); if ( !n ) { printf("TAK\n"); goto kon; } for ( int i=0; i<num_f; i++ ) if ( !(n%F[i]) ) { int c = n/F[i]; int d = num_f-1; while ( d && F[d]!=c ) d--; if ( F[d]==c ) { printf("TAK\n"); goto kon; } } printf("NIE\n"); kon:; } return 0; } |
English