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
#define endl "\n"
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin>>n;
vector<int> v(n),d(n); for(int& i : v) cin>>i;
vector<int> pre(n+1);
for(int i = 0; i<n; i++){
int temp = 0;
int x = v[i];
while(x%2 == 0) x/=2, temp++;
d[i] = temp;
pre[i+1] = pre[i] + (1ll<<temp);
// cerr<<pre[i+1]<<" ";
}
// cerr<<endl;
int q; cin>>q;
while(q--){
int x; cin>>x; x--;
int idx = upper_bound(pre.begin(), pre.end(), x) - pre.begin()-1;
x-=pre[idx];
// looking for x
// cout<<idx<<" ";
cout<<v[idx]/(1ll<<d[idx])<<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... |