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 <iostream>
#include <vector>
#define int long long
#define lgm cin.tie(0)->sync_with_stdio(0);
using namespace std;
signed main() {
lgm;
int n,x;
cin >> n;
vector<int> idx={0};
vector<int> val={0};
for (int i=0;i<n;i++) {
cin >> x;
int cnt=0;
while (x%2==0) {
x/=2;
cnt++;
}
idx.push_back(idx.back()+(1<<cnt));
val.push_back(x);
}
int q;
cin >> q;
while (q--) {
cin >> x;
int l=1,r=n,m;
while (l<r) {
m=(l+r)>>1;
if (idx[m] >= x) {
r=m;
} else {
l=m+1;
}
}
cout << val[l] << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |