#include <bits/stdc++.h>
using namespace std;
long long tab[200005];
long long dwa[40];
void D(){
dwa[0] = 1;
for(int i = 1; i <= 31; i++) dwa[i] = dwa[i-1]*2;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
D();
int n;
cin >> n;
for(int i = 0; i < n; i++) cin >> tab[i];
int q;
cin >> q;
long long l = 0;
int ind = 0;
while(q--){
long long x;
long long occ, val;
cin >> x;
if(x <= l){
cout << val <<'\n';
continue;
}
//cerr << ind << " " << tab[ind] << " " << l << " " << x<< ":"<<'\n';
while(l < x){
//cerr << occ << " " << val << " " << l << '\n';
occ = 1, val = tab[ind];
for(int i = 30; i >= 0; i--){
if(val % dwa[i] == 0){
//cerr << i << '\n';
occ *= dwa[i];
val /= dwa[i];
}
}
ind++;
l += occ;
}
cout << val << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
25 ms |
2644 KB |
Output is correct |
4 |
Correct |
20 ms |
2140 KB |
Output is correct |
5 |
Correct |
42 ms |
3924 KB |
Output is correct |
6 |
Correct |
29 ms |
2900 KB |
Output is correct |
7 |
Correct |
43 ms |
3884 KB |
Output is correct |
8 |
Correct |
42 ms |
4180 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 |
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 |
0 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 |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
496 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 |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
25 ms |
2644 KB |
Output is correct |
4 |
Correct |
20 ms |
2140 KB |
Output is correct |
5 |
Correct |
42 ms |
3924 KB |
Output is correct |
6 |
Correct |
29 ms |
2900 KB |
Output is correct |
7 |
Correct |
43 ms |
3884 KB |
Output is correct |
8 |
Correct |
42 ms |
4180 KB |
Output is correct |
9 |
Correct |
1 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 |
0 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 |
604 KB |
Output is correct |
19 |
Correct |
1 ms |
496 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 |
27 ms |
2896 KB |
Output is correct |
24 |
Correct |
32 ms |
4180 KB |
Output is correct |
25 |
Correct |
58 ms |
7248 KB |
Output is correct |
26 |
Correct |
44 ms |
4688 KB |
Output is correct |
27 |
Correct |
36 ms |
4432 KB |
Output is correct |
28 |
Correct |
62 ms |
7640 KB |
Output is correct |
29 |
Correct |
61 ms |
7248 KB |
Output is correct |
30 |
Correct |
24 ms |
3676 KB |
Output is correct |
31 |
Correct |
64 ms |
7508 KB |
Output is correct |