Wrong Answer
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];
vector<int>dp(n+2,0);
ll cur=1;
for(int i=1;i<=n;i++){
cur*=a[i];
cur%=x;
if(cur==0){
cur=1;
dp[i]=1;
}
dp[i]+=dp[i-1];
}
int q;
cin>>q;
while(q--){
int l,r;
cin>>l>>r;
cout<<(dp[r]-dp[l-1]>0?"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 19:48:05
- Judged At
- 2024-12-17 11:26:14
- Judged By
- Score
- 1
- Total Time
- 25ms
- Peak Memory
- 764.0 KiB