#include <stdio.h> int main(){ // compute fibonacci numbers int count = 250; int fib[250]; fib[0] = 0; fib[1] = 1; for(int i = 2; i < count; i++) { fib[i] = fib[i-1] + fib[i-2]; //printf("%d\n", fib[i]); } // read number of tests int t; scanf("%d", &t); // read tests for(int ti = 0; ti < t; ti++){ int n; scanf("%d",&n); bool flag = false; for(int i = 0; i < count; i++) { for(int j = 0; j < count; j++) { if ((fib[i] * fib[j]) == n){ flag = true; //printf("%d %d\n",fib[i], fib[j]); break; } } if (flag) break; } if (flag) printf("TAK\n"); else printf("NIE\n"); } //int finish; //scanf("%d",&finish); 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 | #include <stdio.h> int main(){ // compute fibonacci numbers int count = 250; int fib[250]; fib[0] = 0; fib[1] = 1; for(int i = 2; i < count; i++) { fib[i] = fib[i-1] + fib[i-2]; //printf("%d\n", fib[i]); } // read number of tests int t; scanf("%d", &t); // read tests for(int ti = 0; ti < t; ti++){ int n; scanf("%d",&n); bool flag = false; for(int i = 0; i < count; i++) { for(int j = 0; j < count; j++) { if ((fib[i] * fib[j]) == n){ flag = true; //printf("%d %d\n",fib[i], fib[j]); break; } } if (flag) break; } if (flag) printf("TAK\n"); else printf("NIE\n"); } //int finish; //scanf("%d",&finish); return 0; } |