#include<bits/stdc++.h>
typedef long long ll;
#define fi first
#define se second
#define pii pair<ll,ll>
#define N 200005
#define endl '\n'
using namespace std;
ll n, a[N], pf[N], c[N], q;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i ++) {
cin >> a[i];
c[i] = 0;
ll u = a[i], cnt = 0;
while (u % 2 == 0) {
u /= 2;
cnt ++;
}
c[i] = (1LL << cnt);
pf[i] = pf[i - 1] + c[i];
a[i] = u;
}
cin >> q;
/*for (int i = 1; i <= n; i ++) {
cout << pf[i] << " " << a[i] << endl;;
}
cout << endl;*/
for (int i = 1; i <= q; i ++) {
ll u; cin >> u;
auto it = lower_bound(pf + 1, pf + 1 + n, u) - pf;
//cout << "u " << u << " " << it << endl;
cout << a[it] << endl;
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |