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>
#define int long long
using namespace std;
int Dos(int n)
{
return (n & (~(n - 1)));
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
map<int,int>m;
vector<int>v;
map<int,int>m2;
int cont = 0;
for(int i = 0 ; i < n ; i++){
int a; cin >> a;
if(!(a & 1)){
int l = Dos(a);
cont += l - 1;
v.push_back(cont);
if(l == a){
m[cont] = 1;
}
else
m[cont] = a / l;
}
else
m[cont] = a;
cont++;
}
int ms ;
cin >> ms;
for(int i = 0 ; i < ms ; i++){
int k ; cin >> k;
if(m[k - 1] != 0){
cout << m[k - 1] << "\n";
}
else{
for(int x : v){
if(k - 1<= x){
cout << m[x] << "\n";
break;
}
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |