首页 > 技术文章 > CF1538D.Another Problem About Dividing Numbers

OvOq 2021-07-10 17:11 原文

传送门

思路

最多操作为将\(a,b\)都向\(1\)转化,次数为两者的质因子的幂次之和。
最少操作次数为将\(a,b\)都向\(gcd(a,b)\)转化,次数为0~2
判断\(k\)是不是在两者之间即可。

代码

const int maxn=2e5+100;
 
int cul(int x){
	int res=0;
	for(int i=2;i*i<=x;i++){
		if(x%i==0){
			while(x%i==0) x/=i,res++;
		}
	}
	if(x>1) res++;
	return res;
}
 
int main(){
	int _=read;
	while(_--){
		int a=read,b=read,k=read;
		if(k==1){
			if(a==b) puts("NO");
			else if(a%b==0||b%a==0) puts("YES");
			else puts("NO");
			continue;
		}
		ll sum=cul(a)+cul(b);
		if(sum>=k) puts("YES");
		else puts("NO");
	}
	return 0;
}
 

推荐阅读