#include<bits/stdc++.h>
#define ld long double
#define pii pair<long long,int>
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define pb push_back
#define f first
#define s second
#define vi vector<ll>
#define vvi vector<vi>
#define vpii vector<pii>
#define ll long long
#define sz(x) (int)x.size()
using namespace std;
ll cnt(ll x){
int tt=0;
while(x%2==0)tt++,x/=2;
return tt;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n;cin>>n;
ll a[n+1];for(int i=1;i<=n;i++)cin>>a[i];
ll qs[n+1];
ll pw[64];pw[0]=1;
for(int i=1;i<=63;i++)pw[i]=2*pw[i-1];
qs[1]=(1<<cnt(a[1]));
for(int i=2;i<=n;i++)qs[i]=qs[i-1]+pw[cnt(a[i])];
int q;cin>>q;
for(int i=1;i<=n;i++)while(a[i]%2==0)a[i]/=2;
while(q--){
ll x;cin>>x;
int id = lower_bound(qs+1,qs+n+1,x)-qs;
cout<<a[id]<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
18 ms |
3480 KB |
Output is correct |
4 |
Correct |
24 ms |
2472 KB |
Output is correct |
5 |
Correct |
41 ms |
5468 KB |
Output is correct |
6 |
Correct |
25 ms |
4188 KB |
Output is correct |
7 |
Correct |
41 ms |
5460 KB |
Output is correct |
8 |
Correct |
40 ms |
5716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
18 ms |
3480 KB |
Output is correct |
4 |
Correct |
24 ms |
2472 KB |
Output is correct |
5 |
Correct |
41 ms |
5468 KB |
Output is correct |
6 |
Correct |
25 ms |
4188 KB |
Output is correct |
7 |
Correct |
41 ms |
5460 KB |
Output is correct |
8 |
Correct |
40 ms |
5716 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
22 ms |
3168 KB |
Output is correct |
24 |
Correct |
29 ms |
5204 KB |
Output is correct |
25 |
Correct |
53 ms |
8788 KB |
Output is correct |
26 |
Correct |
38 ms |
5636 KB |
Output is correct |
27 |
Correct |
39 ms |
5460 KB |
Output is correct |
28 |
Correct |
66 ms |
9540 KB |
Output is correct |
29 |
Correct |
61 ms |
8656 KB |
Output is correct |
30 |
Correct |
31 ms |
3688 KB |
Output is correct |
31 |
Correct |
65 ms |
9264 KB |
Output is correct |