#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX_FIB 24
int main() {
ios_base::sync_with_stdio(0);
long fib[MAX_FIB];
long a = 0, b = 1, c, t, n;
vector<long> ilo;
fib[0] = 0;
fib[1] = 1;
for(int i = 2; i < MAX_FIB; i++) {
c = a + b; a = b; b = c;
fib[i] = b;
}
for(int i = 2; i < MAX_FIB; i++)
for(int j = i; j < MAX_FIB; j++)
ilo.push_back(fib[i] * fib[j]);
sort(ilo.begin(), ilo.end());
cin >> t;
for(int i = 0; i < t; i++) {
cin >> n;
cout << (binary_search(ilo.begin(), ilo.end(), n) ? "TAK" : "NIE") << endl;
}
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 | #include<iostream> #include<vector> #include<algorithm> using namespace std; #define MAX_FIB 24 int main() { ios_base::sync_with_stdio(0); long fib[MAX_FIB]; long a = 0, b = 1, c, t, n; vector<long> ilo; fib[0] = 0; fib[1] = 1; for(int i = 2; i < MAX_FIB; i++) { c = a + b; a = b; b = c; fib[i] = b; } for(int i = 2; i < MAX_FIB; i++) for(int j = i; j < MAX_FIB; j++) ilo.push_back(fib[i] * fib[j]); sort(ilo.begin(), ilo.end()); cin >> t; for(int i = 0; i < t; i++) { cin >> n; cout << (binary_search(ilo.begin(), ilo.end(), n) ? "TAK" : "NIE") << endl; } return 0; } |
English