제출 #1164898

#제출 시각아이디문제언어결과실행 시간메모리
1164898adhityamvIntercastellar (JOI22_ho_t1)C++20
100 / 100
40 ms5444 KiB
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
#include <stack>
using namespace std;
#define int long long
#define mp make_pair
#define fi first
#define pii pair<int,int>
#define se second
const int INF=1000000000000000000;
//const int INF=1e9;
const int N=1000000;
const int M=7+1e9;
const int ln=20;
struct Mint{   
    int n;
    Mint(int nn){
        n=nn%M;
    }
    Mint(){
        n=0;
    }
    Mint& operator+=(Mint const& m){
        n=(n+m.n)%M;
        return *this;
    }
    Mint& operator*=(Mint const& m){
        n=(n*m.n)%M;
        return *this;
    }
    Mint& operator-=(Mint const& m){
        n=(n+M-m.n)%M;
        return *this;
    }
    friend Mint binpow(Mint a,int b){
        if(b==0) return Mint(1);
        Mint r=binpow(a,b/2LL);
        r*=r;
        if(b%2==0) return r;
        r*=a;
        return r;
    }
    friend Mint inverse(Mint a){
        return binpow(a,M-2);
    }
    Mint& operator/=(Mint const &b){
        return (*this)*=inverse(b);
    }
    friend Mint operator+(Mint a,Mint const b){
        return (a+=b);
    }
    friend Mint operator-(Mint a,Mint const b){
        return (a-=b);
    }
    friend Mint operator*(Mint a,Mint const b){
        return (a*=b);
    }
    friend Mint operator/(Mint a,Mint const b){
        return (a/=b);
    }
    friend Mint operator-(Mint a){
        return 0-a;
    }
    friend std::ostream& operator<<(std::ostream& os, Mint const& a){
        return os << a.n;
    }
    friend std::istream& operator>>(std::istream& is, Mint& a){
        return (is >> a.n);
    }
    friend bool operator==(Mint const& a,Mint const& b){
        return a.n==b.n;
    }
    friend bool operator!=(Mint const& a,Mint const& b){
        return a.n!=b.n;
    }
};
template<typename T>
std::ostream& operator<< (std::ostream& os,pair<T,T> p){
    return os << p.fi << "," << p.se << " ";
}
int v2(int n){
    int k=0;
    while(n%(2LL)==0LL){
        n/=(2LL);
        k++;
    }
    return k;
}
void solve(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int b[n];
    for(int i=0;i<n;i++){
        b[i]=(1<<v2(a[i]));
    }
    int q;
    cin >> q;
    int sum=0;
    int ind=0;
    for(int qq=0;qq<q;qq++){
        int xi;
        cin >> xi;
        xi--;
        while(sum+b[ind]<=xi){
            sum+=b[ind];
            ind++;
        }
        cout << (a[ind]/b[ind])<< "\n";
    }
}
signed main(){
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t;
    //cin >> t;
    t=1;
    while(t--) solve();
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...