文章

246

粉丝

0

获赞

1202

访问

193.8k

头像
最大公约数和最小公倍数 题解:

#include<iostream>
using namespace std;

int gcd(int a,int b)
{
	return b==0 ? a : gcd(b,a%b);
}
int main()
{
	int a,b;
	cin>>a>>b;
	if(a<b)
		swap(a,b);
	int res1=gcd(a,b);
	int res2=a*b/res1;
	cout<<res1<<" "<<res2;
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发