#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin>>n;
vector<int> v(n),d(n); for(int& i : v) cin>>i;
vector<int> pre(n+1);
for(int i = 0; i<n; i++){
int temp = 0;
int x = v[i];
while(x%2 == 0) x/=2, temp++;
d[i] = temp;
pre[i+1] = pre[i] + (1ll<<temp);
// cerr<<pre[i+1]<<" ";
}
// cerr<<endl;
int q; cin>>q;
while(q--){
int x; cin>>x; x--;
int idx = upper_bound(pre.begin(), pre.end(), x) - pre.begin()-1;
x-=pre[idx];
// looking for x
// cout<<idx<<" ";
cout<<v[idx]/(1ll<<d[idx])<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
17 ms |
5468 KB |
Output is correct |
4 |
Correct |
24 ms |
2876 KB |
Output is correct |
5 |
Correct |
41 ms |
7248 KB |
Output is correct |
6 |
Correct |
24 ms |
5456 KB |
Output is correct |
7 |
Correct |
40 ms |
7164 KB |
Output is correct |
8 |
Correct |
40 ms |
7248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
600 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 |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
17 ms |
5468 KB |
Output is correct |
4 |
Correct |
24 ms |
2876 KB |
Output is correct |
5 |
Correct |
41 ms |
7248 KB |
Output is correct |
6 |
Correct |
24 ms |
5456 KB |
Output is correct |
7 |
Correct |
40 ms |
7164 KB |
Output is correct |
8 |
Correct |
40 ms |
7248 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
600 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 |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
22 ms |
3420 KB |
Output is correct |
24 |
Correct |
30 ms |
6736 KB |
Output is correct |
25 |
Correct |
53 ms |
10488 KB |
Output is correct |
26 |
Correct |
36 ms |
6484 KB |
Output is correct |
27 |
Correct |
33 ms |
6736 KB |
Output is correct |
28 |
Correct |
61 ms |
10836 KB |
Output is correct |
29 |
Correct |
70 ms |
10324 KB |
Output is correct |
30 |
Correct |
30 ms |
3920 KB |
Output is correct |
31 |
Correct |
61 ms |
10772 KB |
Output is correct |