#include <bits/stdc++.h>
using namespace std;
long long pow2[200007];
long long odd[200007];
long long pref[200007];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n, q;
cin >> n;
for(int i = 1; i <= n; i++)
{
long long x;
cin >> x;
pow2[i] = 1;
while(x % 2 == 0)
{
pow2[i] *= 2;
x /= 2;
}
odd[i] = x;
pref[i] = pref[i - 1] + pow2[i];
}
cin >> q;
while(q--)
{
long long x;
cin >> x;
long long l, r;
l = 1, r = n;
while(l < r)
{
long long sr = (l + r) / 2;
if(pref[sr] >= x)
{
r = sr;
}
else
{
l = sr + 1;
}
}
cout << odd[l] << endl;
}
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... |