51nod 1012最小公倍数LCM

输入2个正整数A,B,求A与B的最小公倍数。

 
Input
2个数A,B,中间用空格隔开。(1<= A,B <= 10^9)
 
Output
输出A与B的最小公倍数。
 
Input示例
30 105
 
Output示例
210

最小公倍数与最大公约数之间有联系

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 ll gcd(ll x,ll y){
 5     return y?gcd(y,x%y):x;
 6 }
 7 
 8 ll gbs(ll x,ll y){
 9     return x/gcd(x,y)*y;
10 }
11       
12 int main(){
13     ll a,b; 
14     scanf("%lld %lld",&a, &b);
15     ll ans=gbs(a,b); 
16     printf("%lld
",ans);
17     return 0; 
18 } 
原文地址:https://www.cnblogs.com/z-712/p/7381085.html