题解 | #求最小公倍数#

求最小公倍数

https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3

#include <iostream>
#include <string>
#include <vector>
using namespace std;

/*正整数A和正整数B 的最小公倍数是指 能被A和B整除的最小的正整数值,设计一个算法,求输入A和B的最小公倍数。
数据范围: 1≤a,b≤100000 
输入描述:输入两个正整数A和B。
输出描述:输出A和B的最小公倍数。*/

int fun5(int x, int y)
{
	while (x%y)
	{
		int temp = x;
		x = y;
		y = temp%y;
	}
	return y;
}
int main()
{
	int x;
	int y;
	cin >> x;
	cin >> y;
	cout << x*y/fun5(x, y) << endl;

	system("pause");
	return 0;
}

全部评论

相关推荐

明明就不饿:看不懂你到底会啥,什么岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务