标签:style blog http color io for
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2028
题目大意:求最小公倍数,用辗转相除法。
1 #include <stdio.h> 2 int main () 3 { 4 int gcd(int a,int b); 5 int a,b,n,i,c; 6 while (scanf("%d",&n)!=EOF) 7 { 8 scanf ("%d",&a); 9 for (i=1; i<=n-1; i++) 10 { 11 scanf ("%d",&b); 12 c=gcd(a,b); 13 a=a/c*b; 14 } 15 printf ("%d\n",a); 16 } 17 return 0; 18 } 19 int gcd(int a,int b) 20 { 21 if (b==0) 22 return a; 23 return gcd(b,a%b); 24 }
hdu 2028 Lowest Common Multiple Plus,布布扣,bubuko.com
hdu 2028 Lowest Common Multiple Plus
标签:style blog http color io for
原文地址:http://www.cnblogs.com/qq-star/p/3853274.html