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>
#include<algorithm>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define mp make_pair
#define endl "\n"
#define out(x) cout << #x << " = " << x << endl
#define outp(x) cout << #x << ".first = " << x.first << " " << #x << ".second = " << x.second << endl
#pragma GCC optimize("Ofast")
int n,q;
ll arr[200005];
pii res[200005];
vector<ll> pre;
signed main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n;
pre.push_back(0);
for (int i=1;i<=n;i++) {
cin>>arr[i];
ll cnt=1, r=arr[i];
while(1){
if (r%2==1) break;
r/=2; cnt*=2;
}
res[i] = mp(cnt, r);
pre.push_back(pre.back()+cnt);
}
//for (int i=1;i<=n;i++) outp(res[i]), cout<<pre[i]<<endl;
cin>>q;
while(q--){
ll x; cin>>x;
int pos = lower_bound(pre.begin(),pre.end(),x) - pre.begin();
//cout<<"#";
cout<<res[pos].second<<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... |