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 MAXN 200001
long long n,q;
long long a[MAXN],br[MAXN];
long long pref[MAXN];
int main()
{
cin>>n;
pref[0]=0;
for (long long i=1;i<=n;i++)
{
cin>>a[i];long long x=a[i];
while (x%2==0) {br[i]++;x/=2;}
br[i]=(1<<br[i]);
pref[i]=pref[i-1]+br[i];
}
pref[n+1]=LLONG_MAX;
cin>>q;
for (long long z=0;z<q;z++)
{
long long x;cin>>x;
long long l=1,r=n+1;
long long rez=0;
while (l<=r)
{
long long mid=(l+r)/2;
if (x>pref[mid-1] and x<=pref[mid]) {rez=mid;break;}
else if (x>pref[mid]) l=mid+1;
else r=mid-1;
}
cout<<a[rez]/br[rez]<<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... |