제출 #645379

#제출 시각아이디문제언어결과실행 시간메모리
6453791zaid1Intercastellar (JOI22_ho_t1)C++17
100 / 100
99 ms9364 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...