이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |