This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll divide(ll x) {
ll res = 1;
if (x % 2 == 0)
res = 2*divide(x/2);
return res;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int n;
cin >> n;
vector<ll> nums(n);
for (int i = 0; i < n; i++) {
cin >> nums[i];
}
vector<ll> ps;
ll prev = 0;
for (int i = 0; i < n; i++) {
ps.push_back(prev+divide(nums[i]));
prev = ps.back();
}
int q;
cin >> q;
while (q--) {
ll x;
cin >> x;
auto it = lower_bound(ps.begin(), ps.end(), x);
int idx = it-ps.begin();
ll sz = nums[idx];
while (sz % 2 == 0)
sz /= 2;
cout << sz << '\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... |