#include <stdio.h> int main(void) { unsigned int size = 0, i = 0, tmp = 0, found = 0; unsigned long number = 0, fibA = 0, fibB = 0, decA = 0, decB = 0; tmp = scanf("%u", &size); for(i = 0; i < size; i++) { tmp = scanf("%lu", &number); fibA = 1; fibB = 1; found = 0; do { fibB = fibA + fibB; fibA = fibB - fibA; decA = fibA; decB = fibB; do { if(decB * fibB == number) { found = 1; break; } decA = decB - decA; decB = decB - decA; } while(decA > 0); if(found) { break; } } while(fibB < number); printf("%s\n", found ? "TAK" : "NIE"); } 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 <stdio.h> int main(void) { unsigned int size = 0, i = 0, tmp = 0, found = 0; unsigned long number = 0, fibA = 0, fibB = 0, decA = 0, decB = 0; tmp = scanf("%u", &size); for(i = 0; i < size; i++) { tmp = scanf("%lu", &number); fibA = 1; fibB = 1; found = 0; do { fibB = fibA + fibB; fibA = fibB - fibA; decA = fibA; decB = fibB; do { if(decB * fibB == number) { found = 1; break; } decA = decB - decA; decB = decB - decA; } while(decA > 0); if(found) { break; } } while(fibB < number); printf("%s\n", found ? "TAK" : "NIE"); } return 0; } |