LCM int lcm(int a,int b) { return a/__gcd(a,b)*b; } GCD c++内置函数中__gcd(int a,int b)可以直接返回最大公约数 int 最大公约数 = __gcd(a,b);