#include <iostream> #include <cmath> using namespace std; #include <iostream> #include <cmath> #include <iostream> #include <utility> #include <deque> #include <map> #include <string> #include <stdio.h> #include <time.h> #include <vector> #include <queue> #include <algorithm> #include <string.h> #define MAX_LONG_LONG 9223372036854775807LL #include <stack> using namespace std; int main(){ int t; scanf("%d",&t); vector<long long> fibb; fibb.push_back(1); fibb.push_back(1); int k=1; while(fibb[k]<1000000000) { fibb.push_back(fibb[k-1]+fibb[k]); k++; } while(t--) { int n; scanf("%d",&n); int i=1; bool no = true; while(fibb[i]*fibb[i]<=n) { if(n%fibb[i]==0 && binary_search(fibb.begin(),fibb.end(),n/fibb[i])) { no = false; break; } i++; } if(no) printf("NIE\n"); else printf("TAK\n"); } // system("pause"); 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 | #include <iostream> #include <cmath> using namespace std; #include <iostream> #include <cmath> #include <iostream> #include <utility> #include <deque> #include <map> #include <string> #include <stdio.h> #include <time.h> #include <vector> #include <queue> #include <algorithm> #include <string.h> #define MAX_LONG_LONG 9223372036854775807LL #include <stack> using namespace std; int main(){ int t; scanf("%d",&t); vector<long long> fibb; fibb.push_back(1); fibb.push_back(1); int k=1; while(fibb[k]<1000000000) { fibb.push_back(fibb[k-1]+fibb[k]); k++; } while(t--) { int n; scanf("%d",&n); int i=1; bool no = true; while(fibb[i]*fibb[i]<=n) { if(n%fibb[i]==0 && binary_search(fibb.begin(),fibb.end(),n/fibb[i])) { no = false; break; } i++; } if(no) printf("NIE\n"); else printf("TAK\n"); } // system("pause"); return 0; } |