/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 488.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 59ms 668.0 KiB
#4 Accepted 59ms 656.0 KiB
#5 Accepted 242ms 892.0 KiB
#6 Accepted 402ms 876.0 KiB
#7 Time Exceeded ≥1575ms ≥760.0 KiB
#8 Time Exceeded ≥1590ms ≥764.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=5e5+10,MOD=1000000007;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    cin>>t;
    while(t--){
    int n,x;
    cin>>n>>x;
    vector<ll>a(n+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    int q;
    cin>>q;
    while(q--){
    	int l,r;
    	cin>>l>>r;
    	int ok=0;
    	ll cur=1;
    	int cnt=0;
    	for(int i=l;i<=r&&cnt<5000;i++){
    		cur*=a[i];
    		cur%=x;
    		if(cur==0){
    			ok=1;
    			break;
    		}
    		cnt++;
    		
    	}
    	cout<<(ok?"Yes\n":"No\n");
    }
    }
    
        

    
    return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1128 Roy and Product
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-29 15:30:46
Judged At
2024-12-17 11:26:16
Judged By
Score
15
Total Time
≥1590ms
Peak Memory
≥892.0 KiB