이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll fun(ll brojic)
{
while (brojic % 2 == 0)
brojic /= 2;
return brojic;
}
ll pow2(int n)
{
ll pov = 1;
while (n--) pov *= 2;
return pov;
}
ll funner(ll brojic)
{
int ret = 0;
while (brojic % 2 == 0)
{
ret++;
brojic /= 2;
}
return pow2(ret);
}
int main()
{
int n;
cin >> n;
vector<ll> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
vector<ll> csum(n);
csum[0] = funner(a[0]);
for (int i = 1; i < n; i++) {
csum[i] = csum[i - 1] + funner(a[i]);
}
int q;
cin >> q;
for (int i = 0; i < q; i++)
{
ll x;
cin >> x;
int pos = lower_bound(csum.begin(), csum.end(), x) - csum.begin();
cout << fun(a[pos]) << endl;
}
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... |