hdu-1108 最小公倍数

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=1108

题目类型:

数论

题意概括:

求两个数的最小公倍数

解题思路:

模拟

 

题目:

最小公倍数

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 56011    Accepted Submission(s): 31103


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

 

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

 

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

 

Sample Input
10 14
 

 

Sample Output
70
# include <stdio.h>

int aaa(int x,int y)
{
    int c,d,r,e;
    c=x;
    d=y;
    while(r=x%y,r!=0)
    {
        x=y;
        y=r;
    }
    e=(c/y)*(d/y)*y;
    return e;
}

int main ()
{
    int a,b,c;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        c=aaa(a,b);
        printf("%d\n",c);
    }
    return 0;
}

 

posted @ 2017-06-04 21:38  枫兮云兮君兮  阅读(147)  评论(0编辑  收藏  举报