#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n';
const int M = 2e6+5, MOD = 1e9;
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
vector<int> v(n), p ={0};
for (int &i:v) cin >> i;
for (int &i:v) {
p.push_back(p.back() + gcd(i, (1ll<<30)));
i /= gcd(i, (1ll<<30));
}
int t;
cin >> t;
while (t--) {
int x;
cin >> x;
cout << v[lower_bound(p.begin(), p.end(), x)-p.begin()-1] << endl;
}
return 0;
}
/*
4
14
9
8
12
6
2
3
5
7
11
13
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
25 ms |
4616 KB |
Output is correct |
4 |
Correct |
30 ms |
2504 KB |
Output is correct |
5 |
Correct |
56 ms |
5680 KB |
Output is correct |
6 |
Correct |
31 ms |
4208 KB |
Output is correct |
7 |
Correct |
65 ms |
5712 KB |
Output is correct |
8 |
Correct |
52 ms |
5704 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
352 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
25 ms |
4616 KB |
Output is correct |
4 |
Correct |
30 ms |
2504 KB |
Output is correct |
5 |
Correct |
56 ms |
5680 KB |
Output is correct |
6 |
Correct |
31 ms |
4208 KB |
Output is correct |
7 |
Correct |
65 ms |
5712 KB |
Output is correct |
8 |
Correct |
52 ms |
5704 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
320 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
352 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
328 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
31 ms |
3112 KB |
Output is correct |
24 |
Correct |
58 ms |
5340 KB |
Output is correct |
25 |
Correct |
99 ms |
8944 KB |
Output is correct |
26 |
Correct |
59 ms |
5792 KB |
Output is correct |
27 |
Correct |
51 ms |
5700 KB |
Output is correct |
28 |
Correct |
92 ms |
9364 KB |
Output is correct |
29 |
Correct |
76 ms |
8796 KB |
Output is correct |
30 |
Correct |
39 ms |
3864 KB |
Output is correct |
31 |
Correct |
90 ms |
9264 KB |
Output is correct |