弱智题90求调
  • 板块学术版
  • 楼主tangyiqiao
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/4/5 19:59
  • 上次更新2023/10/23 19:19:23
查看原帖
弱智题90求调
850112
tangyiqiao楼主2023/4/5 19:59

P1029 最大公约数和最小公倍数问题

#include<bits/stdc++.h>
using namespace std;
int x,y,ans=0;
int gcd(int a,int b){
	if (a%b==0) return b;
	return gcd(b,a%b);
}
int main(){
	scanf("%d%d",&x,&y);
	for(int i=1;i<sqrt(x*y);i++){
		if((x*y)%i==0&&gcd(i,x*y/i)==x)
		   ans+=2;
	}
	if(sqrt(x*y)==(int) sqrt(x*y)) ans++;
	printf("%d",ans);
	return 0;
}
2023/4/5 19:59
加载中...