제출 #1265848

#제출 시각아이디문제언어결과실행 시간메모리
1265848syanvuIntercastellar (JOI22_ho_t1)C++20
100 / 100
44 ms6980 KiB
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>

#define SS ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#pragma optimize("g", on)
#pragma GCC optimize("03")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
#define int long long
#define all(x) x.begin(),x.end()
#define F first
#define S second


using namespace std;
// using namespace __gnu_pbds; 
// #define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>

const int LG = 20,N = 2e5+1,inf = 1e9,MOD = 998244353;
const double eps = 1e-9;
int T;

void solve() {
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int cnt[n+1]={},pref[n+1]={};
    for(int i=1;i<=n;i++){
        int bit=0;
        while(!((a[i]>>bit)&1)) bit++;
        cnt[i]=(1ll<<bit);
        pref[i]=pref[i-1]+cnt[i];
    }
    int q;
    cin>>q;
    while(q--){
        int x;
        cin>>x;
        int it=lower_bound(pref+1,pref+n+1,x)-pref;
        while(pref[it-1]>=x) it--;
        cout<<a[it]/cnt[it]<<'\n';
    }
    return;
}
signed main() {
    //   freopen("deleg.in","r",stdin);    
    // freopen("deleg.out","w",stdout);
    SS
    int t = 1;
    if (T) {
        cin >> t;
    }
    while (t--) {
        solve();
    }
}
/*
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...