//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define ll long long
#define int ll
#define pii pair<int, int>
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define M_PI 3.14159265358979323846
#define all(v) v.begin(), v.end()
#define pss pair<string, string>
#define no cout<<"NO"<<endl;
#define yes cout<<"YES"<<endl;
#define imp cout<<-1<<endl;
#define was cout<<ans<<endl;
#define flu cout.flush();
#define Endl endl
const int N = 200009;
const int mod = 1e9+7;
void solve(){
int n;
cin>>n;
vector<int>a;
for(int i=0; i<n; i++){
int x;
cin>>x;
a.pb(x);
}
vector<int>quv;
int q=1;
for(int i=0; i<35; i++){
q=1;
for(int j=0; j<i; j++){
q=q*2;
}
if(q>INT_MAX){
break;
}
quv.pb(q);
}
sort(all(quv));
reverse(all(quv));
vector<int>e, s;
for(int i=0; i<n; i++){
for(int k : quv){
if(a[i]%k==0){
e.pb(a[i]/k);
s.pb(k);
break;
}
}
}
vector<int>cems;
int sum=0;
for(int i=0; i<n; i++){
sum+=s[i];
cems.pb(sum);
}
int querry;
cin>>querry;
while(querry--){
cin>>q;
int ind=lower_bound(all(cems), q)-cems.begin();
cout<<e[ind]<<endl;
}
}
signed main(){
io;
int 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... |