/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 4ms 3.562 MiB
#2 Accepted 5ms 3.52 MiB
#3 Accepted 152ms 3.773 MiB
#4 Accepted 153ms 3.844 MiB
#5 Accepted 81ms 3.875 MiB
#6 Accepted 81ms 3.785 MiB
#7 Accepted 91ms 3.957 MiB
#8 Accepted 87ms 3.914 MiB
#9 Accepted 87ms 3.938 MiB
#10 Accepted 109ms 4.441 MiB
#11 Accepted 111ms 4.699 MiB
#12 Accepted 107ms 4.48 MiB
#13 Accepted 86ms 3.973 MiB
#14 Accepted 86ms 3.941 MiB
#15 Accepted 164ms 3.801 MiB
#16 Accepted 165ms 3.84 MiB
#17 Accepted 167ms 3.91 MiB
#18 Accepted 158ms 3.844 MiB
#19 Accepted 82ms 3.789 MiB
#20 Accepted 90ms 3.973 MiB
#21 Accepted 110ms 4.703 MiB
#22 Accepted 108ms 4.645 MiB
#23 Accepted 108ms 4.602 MiB
#24 Accepted 103ms 4.652 MiB
#25 Accepted 104ms 4.754 MiB
#26 Accepted 172ms 3.891 MiB
#27 Accepted 209ms 5.105 MiB

Code

#define _GLIBCXX_FILESYSTEM
#include<bits/stdc++.h>
using namespace std;
#define ll long long

const int N = 1e5+2;

ll a[N];

struct ST{
    #define lc (n<<1)
    #define rc (n<<1)|1
    ll t[4*N],x;
    ST(ll _x){
        memset(t,0,sizeof(t));
        x = _x;
    }

    inline ll combine(ll a,ll b){
        return a * b % x;
    }


    inline void build(ll n,ll b,ll e){
        if(b==e){
            t[n]=a[b];
            return;
        }
        ll mid=(b+e)>>1;
        build(lc,b,mid);
        build(rc,mid+1,e);
        t[n]=combine(t[lc],t[rc]);
    }

    inline ll get(ll n,ll b,ll e,ll qb,ll qe){
        if(e<qb || b>qe) return 1;
        if(b>=qb && e<=qe){
            return t[n];
        }
        ll mid=(b+e)>>1;
        return combine(get(lc,b,mid,qb,qe),get(rc,mid+1,e,qb,qe));
    }
};


void solve() {
    ll n,x;
    cin >> n >> x;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    ST st(x);
    st.build(1,1,n);
    int q;
    cin >> q;
    while(q--) {
        int l,r;
        cin >> l >> r;
        if(st.get(1,1,n,l,r) == 0) cout << "Yes\n";
        else cout << "No\n";
    }
    return;
}

int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tc = 1;
    cin >> tc;
    for(int kase = 1; kase <= tc; kase++) {
        //cout << "Case " << kase << ": ";
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1128 Roy and Product
Contest
Brain Booster #7
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-05 15:09:53
Judged At
2024-11-11 02:31:21
Judged By
Score
100
Total Time
209ms
Peak Memory
5.105 MiB