HDU 1019 Least Common Multiple
求多个数的lcm,水题~
int n;
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
int lcm(int a,int b)
{
return a/gcd(a,b)*b;
}
int main()
{
int T;
cin>>T;
while(T--)
{
cin>>n;
vector<int> v(n);
for(int i=0;i<n;i++) cin>>v[i];
for(int i=0;i<n-1;i++)
v[i+1]=lcm(v[i],v[i+1]);
cout<<v[n-1]<<endl;
}
//system("pause");
return 0;
}