在求最小公倍数时要先除后乘。
#include<iostream>
#include<algorithm>
using namespace std;
int LCM(int a,int b)
{
int m=a;
int n=b;
/* if(a<b)
{
int t=a;
a=b;
b=t;
}*/
int r=a%b;
while(r)
{
a=b;
b=r;
r=a%b;
}
return (m/b*n);//先除后乘
}
int main()
{
int T,n,m,t;
cin>>T;
while(T--)
{
cin>>n;t=1;
while(n--)
{
cin>>m;
t=LCM(m,t);
// cout<<t<<endl;
}
cout<<t<<endl;
}
system("pause");
return 0;
}