AcWing 809. 最小公倍数
1. 地址
https://www.acwing.com/problem/content/811/
2. 题解
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
/*
两数乘积=两数的最大公因数×两数的最小公倍数
*/
//代表求最大公因数的函数
int gcd(int a,int b){
if(b > a){
swap(a,b);
}
if(a % b == 0){
return b;
}
gcd(b,a%b);
}
int lcm(int a,int b){
return (a*b)/gcd(a,b);
}
int main(){
int a,b;
scanf("%d %d",&a,&b);
printf("%d",lcm(a,b));
return 0;
}
标签:return,gcd,公倍数,int,809,include,AcWing
From: https://www.cnblogs.com/gao79135/p/17397000.html