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>
#define int long long
using namespace std;
signed main(){
int n;
cin>>n;
vector<int> v(n),cnt(n),pre(n);
for(int &i:v) cin>>i;
for(int i=0;i<n;i++){
cnt[i]=v[i]&-v[i];
}
for(int i=0;i<n;i++){
pre[i]=cnt[i];
if(i!=0) pre[i]+=pre[i-1];
}
int q;
cin>>q;
while(q--){
int x;
cin>>x;
int l=0,r=n-1,mid;
if(cnt[0]>=x) r=0;
while(r-l>1){
mid=(l+r)>>1;
if(pre[mid]>=x) r=mid;
else l=mid;
}
cout<<(v[r]/cnt[r])<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |