#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5;
int v[MAX_N + 2];
long long frecvPart[MAX_N + 1];
int main() {
int n;
cin >> n;
for ( int i = 1; i <= n; i++ ) {
int x;
cin >> x;
int r = 1;
while ( x % 2 == 0 ) {
x /= 2;
r *= 2;
}
frecvPart[i] = frecvPart[i - 1] + r;
v[i] = x;
}
int q;
cin >> q;
for ( int i = 0; i < q; i++ ) {
int a;
cin >> a;
int l = 0, r = n;
while ( r - l > 1 ) {
int mid = (l + r) / 2;
if ( frecvPart[mid] < a )
l = mid;
else
r = mid;
}
cout << v[r] << "\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... |