/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 2ms 324.0 KiB
#3 Wrong Answer 45ms 924.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=2e5+10,MOD=998244353;
typedef long long ll;
#define debug(x) cout<<x<<endl

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    cin>>t;
    while(t--){
    	int n,x;
    	cin>>n>>x;
    	vector<int>a(n+1);
    	for(int i=1;i<=n;i++)cin>>a[i];
    	map<int,int>p;
    	for(int i=2;i<=sqrt(x);i++){
    		while(x>1 && x%i==0){
    			p[i]++;
    			x/=i;
    		}
    	}
    	vector<map<int,int>>prefix(n+2);
    	for(int i=1;i<=n;i++){
    		for(auto it:p){
    			prefix[i][it.first]=prefix[i-1][it.first];
    			while(a[i]%it.first==0){
    				prefix[i][it.first]++;
    				a[i]/=it.first;
    			}
    		}
    		
    	}
    	int q;
    	cin>>q;
    	while(q--){
    		int l,r;
    		cin>>l>>r;
    		l--;
    		int ok=1;
    		for(auto i:p){
    			int total=prefix[r][i.first]-prefix[l][i.first];
    			ok&=(total>=i.second);
    		}
    		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-11-18 17:03:43
Judged At
2024-12-17 11:26:01
Judged By
Score
1
Total Time
45ms
Peak Memory
924.0 KiB