제출 #538650

#제출 시각아이디문제언어결과실행 시간메모리
538650emsilverfoxIntercastellar (JOI22_ho_t1)C++14
100 / 100
470 ms5328 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...