Time Exceeded
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