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;
typedef long long ll;
int main() {
int n; cin>>n;
vector<ll> p(n);
vector<int> eind;
ll m=0;
for (int i=0; i<n; i++) {
cin>>p[i];
m=max(m,p[i]);
if (p[i]%2==0) {
eind.push_back(i);
}
}
vector<ll> c(n); // pf of no of nos p[i] divides into
for (int i=0; i<n; i++) {
if (i==0) {
c[i]=p[i]&-p[i];
} else {
c[i]=c[i-1]+(p[i]&-p[i]);
}
}
int q; cin>>q;
while (q--) {
ll x; cin>>x;
auto it=lower_bound(c.begin(),c.end(),x);
int ind=it-c.begin();
ll n;//no of elements in that
if (ind==0) n=*it;
else n=*it-c[ind-1];
if (n==1) cout<<p[ind]<<"\n";
else if (n==p[ind]) cout<<1<<"\n";
else cout<<p[ind]/n<<"\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... |