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 ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;
ll get(ll x, ll k){
if(x & 1) return x;
ll y = x / 2;
ll cnt = y & -y;
if(cnt < k)return get(x / 2, k - cnt);
return get(x / 2, k);
}
ll lsb(ll x){
return x & -x;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
ll a[n + 1];
for(int i = 1; i <= n; i++){
cin >> a[i];
}
int q; cin >> q;
ll cnt = 0;
int ind = 1;
for(int i = 1; i <= q; i++){
ll x; cin >> x;
while(cnt + lsb(a[ind]) < x)ind++, cnt += lsb(a[ind - 1]);
cout << get(a[ind], x - cnt) << "\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... |