#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";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
78 ms |
4456 KB |
Output is correct |
4 |
Correct |
215 ms |
2912 KB |
Output is correct |
5 |
Correct |
312 ms |
6252 KB |
Output is correct |
6 |
Correct |
166 ms |
4808 KB |
Output is correct |
7 |
Correct |
319 ms |
6208 KB |
Output is correct |
8 |
Correct |
308 ms |
6464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
544 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
472 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
78 ms |
4456 KB |
Output is correct |
4 |
Correct |
215 ms |
2912 KB |
Output is correct |
5 |
Correct |
312 ms |
6252 KB |
Output is correct |
6 |
Correct |
166 ms |
4808 KB |
Output is correct |
7 |
Correct |
319 ms |
6208 KB |
Output is correct |
8 |
Correct |
308 ms |
6464 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
544 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
472 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
179 ms |
3176 KB |
Output is correct |
24 |
Correct |
180 ms |
5656 KB |
Output is correct |
25 |
Correct |
347 ms |
9376 KB |
Output is correct |
26 |
Correct |
208 ms |
6344 KB |
Output is correct |
27 |
Correct |
172 ms |
6340 KB |
Output is correct |
28 |
Correct |
371 ms |
10156 KB |
Output is correct |
29 |
Correct |
374 ms |
9668 KB |
Output is correct |
30 |
Correct |
246 ms |
3964 KB |
Output is correct |
31 |
Correct |
374 ms |
10108 KB |
Output is correct |