# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
979110 | 2024-05-10T09:02:28 Z | vjudge1 | Intercastellar (JOI22_ho_t1) | C | 0 ms | 0 KB |
#include<bits/stdc++.h> #define ft first #define sd second #define pb push_back #define nl "\n" #define int ll typedef long long ll; typedef long double ld; using namespace std; const int mod = 1e9 + 7; const int N = 2000; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T = 1; while(T--) { int n; cin >> n; int a[n + 1]; vector<vector<int>> v; for (int i = 1; i <= n; i++) { cin >> a[i]; int cnt = 1; while(a[i] % 2 == 0) { cnt *= 2; a[i] /= 2; } v.push_back({cnt, a[i]}); } int pre[n + 3]; pre[0] = 0; //cout << pre[0] << ' '; for (int i = 1; i < n; i++) { pre[i] = pre[i - 1] + v[i - 1][0]; // cout << pre[i] << ' '; } //cout << nl; int q; cin >> q; while(q--) { int x; cin >> x; int l = 0, r = n + 1; while(l + 1 < r) { int m = (l + r) / 2; if (x > pre[m]) { l = m; } else { r = m; } } cout << v[l][1] << nl; } } }