#include <stdio.h> const long long int fib[]={1LL, 1LL, 2LL, 3LL, 5LL, 8LL, 13LL, 21LL, 34LL, 55LL, 89LL, 144LL, 233LL, 377LL, 610LL, 987LL, 1597LL, 2584LL, 4181LL, 6765LL, 10946LL, 17711LL, 28657LL, 46368LL, 75025LL, 121393LL, 196418LL, 317811LL, 514229LL, 832040LL, 1346269LL, 2178309LL, 3524578LL, 5702887LL, 9227465LL, 14930352LL, 24157817LL, 39088169LL, 63245986LL, 102334155LL, 165580141LL, 267914296LL, 433494437LL, 701408733LL}; int main() { int n,i,j; long long int m; scanf("%d\n",&n); for(;n>0;n--) { scanf("%Ld\n",&m); for(i=0;i<44;i++) { for(j=0;j<44;j++) { if(fib[i]*fib[j]==m) { printf("TAK\n"); i=46; break; } } } if(i==44) 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 | #include <stdio.h> const long long int fib[]={1LL, 1LL, 2LL, 3LL, 5LL, 8LL, 13LL, 21LL, 34LL, 55LL, 89LL, 144LL, 233LL, 377LL, 610LL, 987LL, 1597LL, 2584LL, 4181LL, 6765LL, 10946LL, 17711LL, 28657LL, 46368LL, 75025LL, 121393LL, 196418LL, 317811LL, 514229LL, 832040LL, 1346269LL, 2178309LL, 3524578LL, 5702887LL, 9227465LL, 14930352LL, 24157817LL, 39088169LL, 63245986LL, 102334155LL, 165580141LL, 267914296LL, 433494437LL, 701408733LL}; int main() { int n,i,j; long long int m; scanf("%d\n",&n); for(;n>0;n--) { scanf("%Ld\n",&m); for(i=0;i<44;i++) { for(j=0;j<44;j++) { if(fib[i]*fib[j]==m) { printf("TAK\n"); i=46; break; } } } if(i==44) printf("NIE\n"); } return 0; } |