/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 2ms 540.0 KiB
#3 Accepted 47ms 736.0 KiB
#4 Accepted 89ms 848.0 KiB
#5 Accepted 48ms 1.023 MiB
#6 Accepted 72ms 1.031 MiB
#7 Accepted 58ms 3.16 MiB
#8 Accepted 91ms 3.496 MiB
#9 Accepted 72ms 2.898 MiB
#10 Accepted 89ms 19.52 MiB
#11 Accepted 52ms 10.27 MiB
#12 Accepted 67ms 14.812 MiB
#13 Accepted 60ms 4.082 MiB
#14 Accepted 67ms 3.445 MiB
#15 Accepted 88ms 728.0 KiB
#16 Accepted 78ms 1.004 MiB
#17 Accepted 35ms 1.066 MiB
#18 Accepted 84ms 852.0 KiB
#19 Accepted 56ms 1.27 MiB
#20 Accepted 69ms 3.625 MiB
#21 Accepted 108ms 28.773 MiB
#22 Accepted 113ms 28.719 MiB
#23 Accepted 82ms 10.34 MiB
#24 Accepted 176ms 46.938 MiB
#25 Accepted 52ms 10.574 MiB
#26 Accepted 194ms 768.0 KiB
#27 Accepted 105ms 10.715 MiB

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<=(int)sqrt(x);i++){
    		while(x>1 && x%i==0){
    			p[i]++;
    			x/=i;
    		}
    	}
    	if(x>1)p[x]++;
    	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:05:19
Judged At
2024-11-18 17:05:19
Judged By
Score
100
Total Time
194ms
Peak Memory
46.938 MiB