#include<bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define ll long long
//#pragma GCC optimize("Ofast, unroll-loop")
//#pragma GCC target("avx,avx2")
#pragma GCC optimize("O3")
const int inf=0x3f3f3f3f;
const ll inff=0x3f3f3f3f3f3f3f3f;
const int X=998244353;
ll lb(ll x){
return x&(-x);
}
int a[200005];
ll pre[200005];
signed main(){
ios::sync_with_stdio(0), cin.tie(0);
int n; cin >> n;
for(int i=1 ; i<=n ; i++) cin >> a[i];
for(int i=1 ; i<=n ; i++){
pre[i]=pre[i-1]+lb(a[i]);
}
int q; cin >> q;
while(q--){
ll t; cin >> t;
int pos=0;
for(int jump=n ; jump ; jump>>=1){
while(jump+pos<=n&&pre[jump+pos]<t) pos+=jump;
}
pos++;
cout << (a[pos]/lb(a[pos])) << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |