This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 2e5 + 10;
int n, q;
ll a[maxn], pref[maxn];
void solve()
{
cin >> n;
for (int i = 1; i <= n; i ++)
{
cin >> a[i];
ll bit = 0;
while(a[i] % ((ll)1 << bit) == 0)
bit ++;
bit --;
pref[i] = pref[i - 1] + ((ll)1 << bit);
a[i] /= ((ll)1 << bit);
}
cin >> q;
for (int i = 1; i <= q; i ++)
{
int l = 0, r = n;
ll x;
cin >> x;
while(l <= r)
{
int m = (l + r) / 2;
if (pref[m] < x)
l = m + 1;
else
r = m - 1;
}
cout << a[l] << endl;
}
}
int main()
{
speed();
solve();
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... |