/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 544.0 KiB
#2 Accepted 2ms 524.0 KiB
#3 Accepted 81ms 864.0 KiB
#4 Accepted 79ms 864.0 KiB
#5 Accepted 261ms 900.0 KiB
#6 Accepted 414ms 796.0 KiB
#7 Time Exceeded ≥1573ms ≥828.0 KiB
#8 Time Exceeded ≥1576ms ≥920.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<2500;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 17:18:57
Judged At
2024-12-17 11:26:14
Judged By
Score
15
Total Time
≥1576ms
Peak Memory
≥920.0 KiB