关于OJ1028的参考解法

其中运用了最小公倍数与最大公约数乘积等于两数相乘的定理。

 1 #include <stdio.h>
 2 int main(int argc, char *argv[])
 3 {
 4     int a,b,c,d,e;
 5     scanf("%d %d",&a,&b);
 6     d=a*b;
 7     while(b>0)
 8     {
 9         c=a%b;
10         a=b;
11         b=c;
12     }
13     e=d/a;
14     printf("%d\n",e);
15     return 0;
16 }

 

posted @ 2016-05-28 16:44  Billw  阅读(246)  评论(0编辑  收藏  举报