#include <iostream>
#include <cmath>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
short n;
cin >> n;
unsigned long long A[n]; //len
unsigned long long total_castella[n];
for (int i=0; i<n; i++) {
cin >> A[i];
unsigned long long tmp = A[i];
while (tmp%2 == 0) tmp/=2;
total_castella[i] = A[i]/tmp;
A[i] = tmp;
if (i>0) total_castella[i]+=total_castella[i-1];
}
short Q;
cin >> Q;
for (int i=0; i<Q; i++) {
unsigned long long x;
cin >> x;
int left = 0;
int right = n-1;
int ans = 0;
while (left<=right) {
int mid = left+(right-left)/2;
if (total_castella[mid] >= x) {
ans = mid;
right = mid-1;
}
else left = mid+1;
}
cout << A[ans] << "\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... |