···
include [HTML_REMOVED]
using namespace std;
typedef long long LL;
struct node {
double val;
int x, y;
bool operator<(const node& a) const {
return val < a.val;
}
};
LL w[507];
vector[HTML_REMOVED] num;
int n, m;
int binary_search(LL x) {
double key = log(x);
int l = 0, r = num.size() - 1;
while(l<=r) {
int mid = (l+r) / 2;
if(abs(num[mid].val - key) <= 1e-9) return mid;
else if(num[mid].val > key) r = mid - 1;
else l = mid + 1;
}
return -1;
}
int main()
{
cin >> n >> m;
for(int i=0; i[HTML_REMOVED]> w[i];
for(int i=0; i<n; i)
for(int j=i+1; j<n; j) {
double val = log(w[i]) * w[j];
node tmp = {val, i, j};
num.push_back(tmp);
val = log(w[j]) * w[i];
node ttmp = {val, j, i};
num.push_back(ttmp);
}
sort(num.begin(), num.end());
for(int i=0; i<m; i++) {
LL x; cin >> x;
int pos = binary_search(x);
if(pos == -1) cout << "-1 -1\n";
else cout << w[num[pos].x] << " " << w[num[pos].y] << endl;
}
return 0;
}
···