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 ld long double
#define pii pair<long long,int>
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define pb push_back
#define f first
#define s second
#define vi vector<ll>
#define vvi vector<vi>
#define vpii vector<pii>
#define ll long long
#define sz(x) (int)x.size()
using namespace std;
ll cnt(ll x){
int tt=0;
while(x%2==0)tt++,x/=2;
return tt;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n;cin>>n;
ll a[n+1];for(int i=1;i<=n;i++)cin>>a[i];
ll qs[n+1];
ll pw[64];pw[0]=1;
for(int i=1;i<=63;i++)pw[i]=2*pw[i-1];
qs[1]=(1<<cnt(a[1]));
for(int i=2;i<=n;i++)qs[i]=qs[i-1]+pw[cnt(a[i])];
int q;cin>>q;
for(int i=1;i<=n;i++)while(a[i]%2==0)a[i]/=2;
while(q--){
ll x;cin>>x;
int id = lower_bound(qs+1,qs+n+1,x)-qs;
cout<<a[id]<<'\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |