c++编译
#include <iostream>
#include <stdio.h>
using namespace std;
int gcd(int a,int b){
if(b==0)
return a;
else
return gcd(b,a%b);
}
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF){
//EOF可以用-1来代替
cout<<a*b/gcd(a,b)<<endl;
}
return 0;
}
注释:在求出最大公约数d的基础上,最小公倍数为a*b/d为防治溢出可以写为a/d*b。