#include <stdio.h> int main(void) { unsigned long int num; unsigned short int n; scanf("%hu", &n); while (n > 0) { scanf("%lu", &num); if(num < 3) printf("TAK\n"); else if( check(1, num, 1) == 1) printf("TAK\n"); else printf("NIE\n"); n -= 1; } return 0; } int check (unsigned long b, unsigned long num, int deep) { unsigned long a = 0; unsigned long c = a + b; while (c < 1000000000) { a = b; b = c; c = a + b; if(c == num) return 1; if(deep == 1 && check(c, num, 0) == 1) return 1; } 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 <stdio.h> int main(void) { unsigned long int num; unsigned short int n; scanf("%hu", &n); while (n > 0) { scanf("%lu", &num); if(num < 3) printf("TAK\n"); else if( check(1, num, 1) == 1) printf("TAK\n"); else printf("NIE\n"); n -= 1; } return 0; } int check (unsigned long b, unsigned long num, int deep) { unsigned long a = 0; unsigned long c = a + b; while (c < 1000000000) { a = b; b = c; c = a + b; if(c == num) return 1; if(deep == 1 && check(c, num, 0) == 1) return 1; } return 0; } |