您的位置:首页 > 其它

hdu 1108 最小公倍数

2012-04-03 17:01 218 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1108

View Code

#include<iostream>
#include<cmath>
using namespace std;
int gcd(int a1,int b1)//
{
int a=max(a1,b1);
int b=min(a1,b1);
int temp=a%b;
while(temp!=0)
{
a=b;
b=temp;
temp=a%b;
}
return b;
}
int main()
{
int a,b;
while(cin>>a>>b)
{
cout<<a*b/gcd(a,b)<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: