#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pii pair<int, int>
#define fi first
#define se second
#define __builtin_popcount __builtin_popcountll
#define all(x) (x).begin(), (x).end()
#define BIT(x, i) (((x) >> (i)) & 1)
#define debug(a, l, r) for (int i = (l); i <= (r); ++i) cout << (a)[i] << ' '; cout << '\n';
const int MAXN = 2e5 + 5;
int n, a[MAXN], pref[MAXN];
// {val, cnt}
pii val[MAXN];
signed main() {
#ifdef NCTHANH
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(nullptr); cout.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
int cur = a[i], pw2 = 0;
while (cur % 2 == 0) {
++pw2;
cur /= 2;
}
val[i] = {cur, 1ll << pw2};
pref[i] = pref[i - 1] + val[i].se;
}
int q; cin >> q;
while (q--) {
int x; cin >> x;
int pos = lower_bound(pref + 1, pref + n + 1, x) - pref;
cout << val[pos].fi << '\n';
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |