#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 |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
5648 KB |
Output is correct |
4 |
Correct |
23 ms |
2676 KB |
Output is correct |
5 |
Correct |
40 ms |
7248 KB |
Output is correct |
6 |
Correct |
24 ms |
5464 KB |
Output is correct |
7 |
Correct |
41 ms |
7160 KB |
Output is correct |
8 |
Correct |
46 ms |
7276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
0 ms |
392 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 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 |
500 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 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 |
16 ms |
5648 KB |
Output is correct |
4 |
Correct |
23 ms |
2676 KB |
Output is correct |
5 |
Correct |
40 ms |
7248 KB |
Output is correct |
6 |
Correct |
24 ms |
5464 KB |
Output is correct |
7 |
Correct |
41 ms |
7160 KB |
Output is correct |
8 |
Correct |
46 ms |
7276 KB |
Output is correct |
9 |
Correct |
0 ms |
344 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 |
0 ms |
392 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
344 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 |
500 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
21 ms |
3264 KB |
Output is correct |
24 |
Correct |
28 ms |
6484 KB |
Output is correct |
25 |
Correct |
56 ms |
10472 KB |
Output is correct |
26 |
Correct |
35 ms |
6744 KB |
Output is correct |
27 |
Correct |
32 ms |
6740 KB |
Output is correct |
28 |
Correct |
60 ms |
10836 KB |
Output is correct |
29 |
Correct |
58 ms |
10376 KB |
Output is correct |
30 |
Correct |
31 ms |
3932 KB |
Output is correct |
31 |
Correct |
61 ms |
10832 KB |
Output is correct |