#include <stdio.h>
unsigned int *makefib()
{
static unsigned int fib[44];
unsigned int last = 0, last2 = 1, cnt = 0;
while(cnt < 44)
{
fib[cnt] = last + last2;
last2 = last;
last = fib[cnt];
cnt ++;
}
return fib;
}
int main(void)
{
unsigned short int t = 0, cnt = 0;
unsigned int n = 0, cnt1 = 1, cnt2 = 2;
unsigned char solution = 0;
unsigned int *p;
p = makefib();
scanf("%hu", &t);
while(cnt < t)
{
scanf("%u", &n);
if(n <= 2)
printf("TAK");
else
{
if(n > 866988874)
printf("NIE");
else
{
while(cnt1 < 43 && solution == 0)
{
while(cnt2 < 44 && solution == 0)
{
if(*(p+cnt1) * *(p+cnt2) == n)
{
printf("TAK");
solution = 1;
}
cnt2 ++;
}
cnt2 = 2;
cnt1 ++;
}
cnt1 = 1;
if(solution == 0)
printf("NIE");
solution = 0;
}
}
cnt ++;
if(cnt < t)
printf("\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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #include <stdio.h> unsigned int *makefib() { static unsigned int fib[44]; unsigned int last = 0, last2 = 1, cnt = 0; while(cnt < 44) { fib[cnt] = last + last2; last2 = last; last = fib[cnt]; cnt ++; } return fib; } int main(void) { unsigned short int t = 0, cnt = 0; unsigned int n = 0, cnt1 = 1, cnt2 = 2; unsigned char solution = 0; unsigned int *p; p = makefib(); scanf("%hu", &t); while(cnt < t) { scanf("%u", &n); if(n <= 2) printf("TAK"); else { if(n > 866988874) printf("NIE"); else { while(cnt1 < 43 && solution == 0) { while(cnt2 < 44 && solution == 0) { if(*(p+cnt1) * *(p+cnt2) == n) { printf("TAK"); solution = 1; } cnt2 ++; } cnt2 = 2; cnt1 ++; } cnt1 = 1; if(solution == 0) printf("NIE"); solution = 0; } } cnt ++; if(cnt < t) printf("\n"); } return 0; } |
English