HDOJ1108【最小公倍数。。】

#include <stdio.h>
int lcm(int a,int b)
{
int s,g,l;
g = a>b?a:b;
l = a>b?b:a;
s = g;
while (1)
{
if (s%l==0)
return s;
s+=g;
}
}
int main()
{
int a,b;
while (scanf("%d%d",&a,&b)!=EOF)
printf("%d\n",lcm(a,b));

}

 

posted @ 2012-03-31 14:37  ZH奶酪  阅读(353)  评论(0编辑  收藏  举报