洛谷题单指南-数学基础问题-P4057 [Code+#1] 晨跑
原题链接:https://www.luogu.com.cn/problem/P4057
题意解读:给定三个数,计算其最小公倍数。
解题思路:
三个数a、b、c
lcm(a, b, c) = lcm(lcm(a, b), c)
100分代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a, b, c;
LL gcd(LL a, LL b)
{
if(b == 0) return a;
return gcd(b, a % b);
}
LL lcm(LL a, LL b)
{
return a * b / gcd(a, b);
}
int main()
{
cin >> a >> b >> c;
cout << lcm(lcm(a, b), c);
}