/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 532.0 KiB
#2 Runtime Error 1ms 568.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define N (ll)1e6
ll pw(ll a,ll n,ll md){
    ll an=1;
    while(n!=0){
        if(n%2)
            an=(an*a)%md;
        a=(a*a)%md;
        n/=2;
    }
    return an;
}
ll inv(ll a,ll md){
    return pw(a,md-2ll,md);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1,i=1,j,p,mx,tot,n,a,m,x,y,k,rt,c,b=1,q;
    cin>>t;
    while(t--){
        cin>>n>>x;
        ll ar[n],s=0,hi,lo,mid;
        for(a=0;a<n;a++){
            cin>>ar[a];
            if(a>0)
                ar[a]=ar[a-1]*ar[a];
        }
        cin>>q;
        ll l,r;
        while(q--){
            cin>>l>>r;
            l--;r--;
            if(l==0){
                if(ar[r]%x==0)
                    cout<<"YES\n";
                else
                    cout<<"NO\n";
            }
            else{
                if((ar[r]/ar[l-1])%x==0)
                    cout<<"YES\n";
                else
                    cout<<"NO\n";
            }
        }
    }
}

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:39:56
Judged At
2024-11-11 02:30:14
Judged By
Score
0
Total Time
1ms
Peak Memory
568.0 KiB