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 int long long int
/*
int log(int a, int n){
if(n < a)
return 0;
return log(n/a)+1;
}
int fac(int n){
if(n < 1)
return 1;
return n * fac(n-1);
}*/
int a[200000];
int b[200000];
int pre[200010];
int q[200000];
int32_t main(){
int n;
cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i];
}
int Q;
cin >> Q;
for(int i = 0; i < Q; i++){
cin >> q[i];
}
for(int i = 0; i < n; i++){
b[i] = 1;
}
for(int i = 0; i < n; i++){
while(a[i] % 2 == 0){
b[i] *= 2;
a[i] /= 2;
}
//cout << "suichan " << i << ' ' << a[i] << ' ' << b[i] <<'\n';
}
pre[0] = 0;
for(int i = 0; i < n; i++){
pre[i+1] = pre[i]+b[i];
}
for(int i = 0; i < Q; i++){
cout << a[(lower_bound(pre, pre+n+1, q[i])-pre)-1] << '\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... |