标签:
Description
Input
Output
Sample Input
Sample Output
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 int LCM(int a,int b) 5 { 6 int m=a,n=b; 7 int c; 8 while(b!=0)//辗转相除法 9 { 10 c=a%b; 11 a=b; 12 b=c; 13 } 14 return m/a*n;//之前写的m*n/a 结果是错的 改成这样之后终于AC了 15 } 16 int main() 17 { 18 int a,n,m,num; 19 scanf("%d",&n); 20 while(n--) 21 { 22 num=1; 23 scanf("%d",&m); 24 while(m--) 25 { 26 scanf("%d",&a); 27 num=LCM(a,num); 28 } 29 printf("%d\n",num); 30 } 31 }
标签:
原文地址:http://www.cnblogs.com/guofeng1022/p/4245799.html