/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 332.0 KiB
#2 Runtime Error 1ms 608.0 KiB
#3 Runtime Error 2ms 796.0 KiB

Code

#include "bits/stdc++.h"
using namespace std;
using ll=long long;
void solve();
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cout << setprecision(8) << fixed;
    int t=1;
    cin>>t;
    for(int i=1;i<=t;i++){
        // cout<<"Test case# "<<i<<" ";
         solve();
    }
    return 0;
}
void solve(){
    ll n,x;cin>>n>>x; 
    vector<ll>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]=(a[i]%x)+1;
    }
    vector<ll>pmul(n+1,1);
    for(int i=0;i<n;i++){
        pmul[i+1]=(pmul[i]*a[i]);
    }  
    ll q;cin>>q;  
    while(q--){
        ll l,r;cin>>l>>r; 
        ll reqProd=pmul[r]/pmul[l-1];
        if(reqProd%x==1){
            cout<<"Yes"<<"\n";
        }else{
            cout<<"No\n";
        }
    }
    
}

Information

Submit By
Type
Submission
Problem
P1128 Roy and Product
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-13 06:57:03
Judged At
2024-11-13 06:57:03
Judged By
Score
1
Total Time
2ms
Peak Memory
796.0 KiB