This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
using ll = long long;
void solve(){
ll n;
cin >> n;
vector<vector<ll>> list_n;
ll curr = 1;
for(ll i = 0; i < n; i++){
ll a;
cin >> a;
ll num = 1;
while(a%2 == 0){
num*=2;
a = (ll)a/2;
}
list_n.push_back({curr, curr + num - 1, a});
curr += num;
}
ll q;
cin >> q;
ll N = list_n.size();
for(ll i = 0; i < q; i++){
ll req;
cin >> req;
ll l = 0;
ll r = N;
while(l + 1 < r){
ll mid = (l + r)/2;
if(list_n[mid][0] > req){
r = mid;
}else if(list_n[mid][1] < req){
l = mid;
}else{
l = mid;
break;
}
}
cout << list_n[l][2] << endl;
}
}
int main(){
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
ll t = 1;
//cin >> t;
while(t--){
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |