比较麻烦的写法
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
if (b == 0)
return a;
else
return gcd(b, a % b);
}
int main()
{
int n;
while(cin>>n)
{
while(n--)
{
stack<int>a;
int nums;
cin>>nums;
int x,y;
while(nums--)
{
cin>>x;
a.push(x);
}
while(1)
{
if(a.size() == 1)
break;
x = a.top();
a.pop();
y = a.top();
a.pop();
if(x<y)
swap(x,y);
a.push(x/gcd(x,y)*y);
}
cout<<a.top()<<endl;
a.pop();
}
}
}