#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
const int nmax = 2e5 + 1;
struct numar {
int val, i;
} ax[nmax];
bool cmp(numar a, numar b) {
return a.val < b.val;
}
int check(int x) {
int cnt = 0;
while(x % 2 == 0) {
cnt ++;
x /= 2;
}
return cnt;
}
int ans[nmax], v[nmax];
int main() {
int n;
cin >> n;
for(int i = 1; i <= n; i ++) {
cin >> v[i];
}
int q;
cin >> q;
for(int i = 1; i <= q; i ++) {
cin >> ax[i].val;
ax[i].i = i;
}
sort(ax + 1, ax + q + 1, cmp);
int curr = 0, ult = 0, an = 1;
for(int i = 1; i <= n; i ++) {
if(an == q + 1) {
break;
}
ult = curr;
curr ++;
ult ++;
int x = check(v[i]);
curr += (1 << x) - 1;
if(ult <= ax[an].val && ax[an].val <= curr) {
ans[ax[an].i] = v[i] / (1 << x);
an ++;
i --;
curr -= (1 << x);
ult --;
}
}
for(int i = 1; i <= q; i ++) {
cout << ans[i] << "\n";
}
return 0;
}
Compilation message
cc1plus: error: '::main' must return 'int'