HDU1108最小公倍数 水题

**
Problem Description
给定两个正整数,计算这两个数的最小公倍数。

Input
输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数.

Output
对于每个测试用例,给出这两个数的最小公倍数,每个实例输出一行。

Sample Input

10 14

Sample Output

70**
gcd(a,b) 等价于gcd(b,a%b) (a>b并且a%b!=0)

#include<stdio.h>

int gcd(int a,int b)
{
    int t;
    if( a < b)
    {
        t = a;
        a = b;
        b = t;
    }
    if( a%b == 0)
        return b;
    else
        return gcd(b,a%b);
}

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        printf("%d
",n*m/gcd(n,m));
    }
    return 0;
 } 

后记:这道水题本来是让我找状态的,结果居然PE了一遍,尴尬,,,果然已经沦落到了连水题都切不动的地步了

原文地址:https://www.cnblogs.com/hellocheng/p/7350161.html