This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> a(n);
vector<pair<int, int>> b(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
int pw = 0;
while (a[i] % (1 << (pw + 1)) == 0) {
pw++;
}
b[i] = {1 << pw, a[i] / (1 << pw)};
}
vector<long long> pr_cnt(n + 1);
for (int i = 0; i < n; ++i) {
pr_cnt[i + 1] = pr_cnt[i] + b[i].first;
}
int q;
cin >> q;
while (q--) {
int x;
cin >> x;
x--;
int pos = upper_bound(pr_cnt.begin(), pr_cnt.end(), x) - pr_cnt.begin() - 1;
cout << b[pos].second << '\n';
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |