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 int long long
using namespace std;
ll n,two[37];
vector<ll> posi,value;
signed main()
{
ios_base::sync_with_stdio(false);cin.tie(nullptr);
for(int i=0;i<=30;i++)
{
two[i]=(1<<i);
}
cin>>n;
posi.emplace_back(1);
value.emplace_back(-1);
for(int i=1;i<=n;i++)
{
ll num;
cin>>num;
ll size=0;
for(int i=0;i<=30;i++)
{
if(two[i]>num) break;
if(num%two[i]==0)
{
size=two[i];
}
}
if(posi.size()==1)
posi.emplace_back(size);
else
posi.emplace_back(posi[posi.size()-1]+size);
value.emplace_back(num/size);
}
int q;
cin>>q;
while(q--)
{
ll tmp;
cin>>tmp;
int it=lower_bound(posi.begin(),posi.end(),tmp)-posi.begin();
cout<<value[it]<<"\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... |