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>
#pragma GCC optimize("O3")
using namespace std;
#define islam_zymchybekov void solve()
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define nl cout<<'\n';
#define int long long
typedef vector<int> vi;
typedef pair<int,int> pi;
const int N= 200005;
int n, q, a[N], x;
int b[N], p[N];
islam_zymchybekov{
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
b[i]=1;
while(a[i]%2==0) {
a[i]/=2;
b[i]*=2;
}
}
for(int i=0;i<n;i++)p[i+1]=p[i]+b[i];
cin >> q;
while (q--) {
cin >> x;
int id = lower_bound(p, p + n, x) - p;
id--;
cout<<a[id];nl
}
}
main(){
ios;
int T = 1;
// cin >> T;
while(T--){
solve();
}
//cout<<fixed<<setprecision(10);
//cerr<<"Time:"<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";__int128
}
Compilation message (stderr)
Main.cpp:37:3: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
37 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |