/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 4ms 3.52 MiB
#2 Accepted 5ms 3.566 MiB
#3 Accepted 124ms 3.82 MiB
#4 Accepted 157ms 3.859 MiB
#5 Accepted 68ms 3.773 MiB
#6 Accepted 71ms 3.773 MiB
#7 Accepted 80ms 3.77 MiB
#8 Accepted 83ms 3.77 MiB
#9 Accepted 79ms 3.938 MiB
#10 Accepted 97ms 4.52 MiB
#11 Accepted 90ms 4.621 MiB
#12 Accepted 91ms 4.523 MiB
#13 Accepted 106ms 3.77 MiB
#14 Accepted 76ms 3.77 MiB
#15 Accepted 136ms 3.859 MiB
#16 Accepted 143ms 3.848 MiB
#17 Accepted 128ms 3.77 MiB
#18 Accepted 128ms 3.77 MiB
#19 Accepted 73ms 3.82 MiB
#20 Accepted 78ms 3.789 MiB
#21 Accepted 112ms 4.52 MiB
#22 Accepted 93ms 4.52 MiB
#23 Accepted 90ms 4.637 MiB
#24 Accepted 91ms 4.742 MiB
#25 Accepted 90ms 4.734 MiB
#26 Accepted 160ms 3.727 MiB
#27 Accepted 180ms 5.02 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-05 15:09:53
Judged By
Score
100
Total Time
180ms
Peak Memory
5.02 MiB