이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |