#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,q, ans[200200], arr[200200];
int solve(int n){
int idx = 1;
while(n%2==0){
n/=2;
idx++;
}
return pow(2, idx - 1);
}
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
for(int i = 1; i<=n; ++i) cin >> arr[i];
for(int i = 1; i<=n; ++i){
ans[i] = solve(arr[i]);
ans[i]+=ans[i - 1];
}
cin >> q;
while(q--){
int x; cin >> x;
int i = lower_bound(ans+1, ans+1+n, x) - ans;
cout << arr[i] / (ans[i] - ans[i - 1]) << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
18 ms |
3420 KB |
Output is correct |
4 |
Correct |
24 ms |
3932 KB |
Output is correct |
5 |
Correct |
42 ms |
5460 KB |
Output is correct |
6 |
Correct |
25 ms |
4436 KB |
Output is correct |
7 |
Correct |
44 ms |
5516 KB |
Output is correct |
8 |
Correct |
47 ms |
5968 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
18 ms |
3420 KB |
Output is correct |
4 |
Correct |
24 ms |
3932 KB |
Output is correct |
5 |
Correct |
42 ms |
5460 KB |
Output is correct |
6 |
Correct |
25 ms |
4436 KB |
Output is correct |
7 |
Correct |
44 ms |
5516 KB |
Output is correct |
8 |
Correct |
47 ms |
5968 KB |
Output is correct |
9 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
22 ms |
4776 KB |
Output is correct |
24 |
Correct |
28 ms |
5712 KB |
Output is correct |
25 |
Correct |
66 ms |
8784 KB |
Output is correct |
26 |
Correct |
36 ms |
6224 KB |
Output is correct |
27 |
Correct |
33 ms |
5972 KB |
Output is correct |
28 |
Correct |
65 ms |
9192 KB |
Output is correct |
29 |
Correct |
66 ms |
8788 KB |
Output is correct |
30 |
Correct |
31 ms |
5468 KB |
Output is correct |
31 |
Correct |
62 ms |
9184 KB |
Output is correct |