#include<bits/stdc++.h>
using namespace std;
#define ll long long
const bool Multitest = 0;
const int N = 2e5 + 10;
ll a[N], cnt[N];
int n, q;
void work()
{
cin >> n;
for(int i = 1 ; i <= n ; i++) cin >> a[i];
for(int i = 1 ; i <= n ; i++)
{
cnt[i] = 1;
while(a[i] % 2 == 0)
{
cnt[i] *= 2;
a[i] /= 2;
}
cnt[i] += cnt[i - 1];
}
cin >> q;
while(q--)
{
ll x; cin >> x;
int l = 1, r = n, pos = 0;
while(l <= r)
{
int mid = (l + r) >> 1;
if(cnt[mid] < x) l = mid + 1, pos = mid;
else r = mid - 1;
}
cout << a[pos + 1] << '\n';
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int q = 1;
if(Multitest) cin >> q;
while(q--) work();
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |