#include <stdio.h> enum{ MAX = 46 }; int fib2[MAX][MAX]; void sprawdzFib(int l) { int i,j; for (i=0;i<MAX;i++) { for (j=0;j<MAX;j++) { if (l == fib2[i][j]) { printf("TAK\n"); return; } } } printf("NIE\n"); } int main(void) { int fib[MAX]; fib[0] = 0; fib[1] = 1; int i,j; for (i=2;i<MAX;i++) { fib[i] = fib[i-2] + fib[i-1]; //printf("%d\n", fib[i]); } for (i=0;i<MAX;i++) { for (j=0;j<MAX;j++) { if ((fib[i] < 400000) && (fib[j] < 400000)) { fib2[i][j] = fib[i]*fib[j]; } else { fib2[i][j] = -1; } } } int t; scanf("%d", &t); int l; int ti; for (ti=0;ti<t;ti++) { scanf("%d", &l); sprawdzFib(l); } 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 | #include <stdio.h> enum{ MAX = 46 }; int fib2[MAX][MAX]; void sprawdzFib(int l) { int i,j; for (i=0;i<MAX;i++) { for (j=0;j<MAX;j++) { if (l == fib2[i][j]) { printf("TAK\n"); return; } } } printf("NIE\n"); } int main(void) { int fib[MAX]; fib[0] = 0; fib[1] = 1; int i,j; for (i=2;i<MAX;i++) { fib[i] = fib[i-2] + fib[i-1]; //printf("%d\n", fib[i]); } for (i=0;i<MAX;i++) { for (j=0;j<MAX;j++) { if ((fib[i] < 400000) && (fib[j] < 400000)) { fib2[i][j] = fib[i]*fib[j]; } else { fib2[i][j] = -1; } } } int t; scanf("%d", &t); int l; int ti; for (ti=0;ti<t;ti++) { scanf("%d", &l); sprawdzFib(l); } return 0; } |