#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 |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
69 ms |
5600 KB |
Output is correct |
4 |
Correct |
191 ms |
2844 KB |
Output is correct |
5 |
Correct |
305 ms |
6996 KB |
Output is correct |
6 |
Correct |
134 ms |
5276 KB |
Output is correct |
7 |
Correct |
281 ms |
7252 KB |
Output is correct |
8 |
Correct |
296 ms |
7252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 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 |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
69 ms |
5600 KB |
Output is correct |
4 |
Correct |
191 ms |
2844 KB |
Output is correct |
5 |
Correct |
305 ms |
6996 KB |
Output is correct |
6 |
Correct |
134 ms |
5276 KB |
Output is correct |
7 |
Correct |
281 ms |
7252 KB |
Output is correct |
8 |
Correct |
296 ms |
7252 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 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 |
3 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
162 ms |
3408 KB |
Output is correct |
24 |
Correct |
148 ms |
6480 KB |
Output is correct |
25 |
Correct |
378 ms |
10276 KB |
Output is correct |
26 |
Correct |
206 ms |
6552 KB |
Output is correct |
27 |
Correct |
157 ms |
6640 KB |
Output is correct |
28 |
Correct |
356 ms |
10836 KB |
Output is correct |
29 |
Correct |
336 ms |
10328 KB |
Output is correct |
30 |
Correct |
239 ms |
3924 KB |
Output is correct |
31 |
Correct |
339 ms |
10832 KB |
Output is correct |