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>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <iomanip>
#define ll long long
#define FOR(i,a) for (long long i=0;i<a;i++)
#define FORN(i,a) for (long long i=1;i<=a;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define int long long
using namespace std;
int oo=9e17;
int mod=1e9 + 7;
int a[200001];
int s[51];
map<int,int>pp;
int z[200002];
void solve(){
int o=1;
for(int i=0;i<=50;i++){
s[i]=o;
o*=2;
}
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
int o=0;
while(a[i]%2==0){
o++;
a[i]/=2;
}
pp[i]=a[i];
z[i]=s[o];
}
int q;
cin>>q;
int l=1,sm=0;
while(q--){
int x;
cin>>x;
while(true){
if(sm<=x && x<=sm+z[l]){
cout<<pp[l]<<"\n";
break;
}
sm+=z[l];
l++;
}
}
}
signed main(){
//srand( time(0));
//rand()
//freopen("sum.in", "r", stdin);
//freopen("sum.out", "w", stdout);
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int c=1;
while(c--){
solve();
}
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... |