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;
#ifdef ngu
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = (int) 2e5 + 5;
int n, q;
int a[N];
long long cnt[N];
int get(int &x) {
int res = 1;
while (x % 2 == 0) {
x /= 2;
res *= 2;
}
return res;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
#ifdef ngu
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
#endif
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
cnt[i] = cnt[i - 1] + get(a[i]);
}
cin >> q;
while (q--) {
long long x;
cin >> x;
int p = lower_bound(cnt + 1, cnt + n + 1, x) - cnt;
cout << a[p] << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |