#include <stdio.h> int main() { unsigned long long int fibonacci[45]; unsigned long long int iloczyny[946]; fibonacci[0] = 0; fibonacci[1] = 1; int a,i,j; unsigned int liczba; for(i=2;i<45;++i) { fibonacci[i] = fibonacci[i-1]+fibonacci[i-2]; } int h = 0; for(i=2;i<45;++i) for(j=i;j<45;++j) { iloczyny[h] = fibonacci[i]*fibonacci[j]; if(iloczyny[h] > 1000000000) break; ++h; } scanf("%d",&a); for(j=0;j<a;++j) { scanf("%u",&liczba); for(i=0;i<h-1;++i) { if(liczba == iloczyny[i]) { printf("TAK\n"); break; } } if(i == h-1) printf("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 38 39 | #include <stdio.h> int main() { unsigned long long int fibonacci[45]; unsigned long long int iloczyny[946]; fibonacci[0] = 0; fibonacci[1] = 1; int a,i,j; unsigned int liczba; for(i=2;i<45;++i) { fibonacci[i] = fibonacci[i-1]+fibonacci[i-2]; } int h = 0; for(i=2;i<45;++i) for(j=i;j<45;++j) { iloczyny[h] = fibonacci[i]*fibonacci[j]; if(iloczyny[h] > 1000000000) break; ++h; } scanf("%d",&a); for(j=0;j<a;++j) { scanf("%u",&liczba); for(i=0;i<h-1;++i) { if(liczba == iloczyny[i]) { printf("TAK\n"); break; } } if(i == h-1) printf("NIE\n"); } return 0; } |