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>
using namespace std;
long long tab[200005];
long long dwa[40];
void D(){
dwa[0] = 1;
for(int i = 1; i <= 31; i++) dwa[i] = dwa[i-1]*2;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
D();
int n;
cin >> n;
for(int i = 0; i < n; i++) cin >> tab[i];
int q;
cin >> q;
long long l = 0;
int ind = 0;
while(q--){
long long x;
long long occ, val;
cin >> x;
if(x <= l){
cout << val <<'\n';
continue;
}
//cerr << ind << " " << tab[ind] << " " << l << " " << x<< ":"<<'\n';
while(l < x){
//cerr << occ << " " << val << " " << l << '\n';
occ = 1, val = tab[ind];
for(int i = 30; i >= 0; i--){
if(val % dwa[i] == 0){
//cerr << i << '\n';
occ *= dwa[i];
val /= dwa[i];
}
}
ind++;
l += occ;
}
cout << val << '\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... |