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;
#define int long long
signed main()
{
int n; cin >> n;
vector<int> a(n);
vector<pair<int, int>> inter;
int l = 1;
for (int i = 0; i < n; i++){
cin >> a[i];
int x = a[i];
int next = 1;
while(x % 2 == 0){
x /= 2;
next *= 2;
}
inter.push_back({l, x});
l += next;
}
/*for (auto x : inter){
cout << x.first << ' ' << x.second << endl;
}
cout << endl;*/
int q; cin >> q;
while(q--){
int j; cin >> j;
int ini = 1, fin = inter.size();
while(ini < fin){
int m = (ini + fin) / 2;
if (inter[m].first <= j){
ini = m + 1;
}else fin = m;
}
ini--;
cout << inter[ini].second << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |