이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |