题目地址:http://ac.jobdu.com/problem.php?cid=1040&pid=48
C语言源码:
#include<stdio.h>
#include<math.h>
long long gcd(long long a,int b)
{
return b==0?a:gcd(b,a%b);
}
int main()
{
long long n,m,s,a,i;
while(scanf("%lld",&n)!=EOF)
{
while(n--)
{
scanf("%lld",&m);
for(i=0;i<m;i++)
{
scanf("%lld",&s);
if(i==0)
a=s;
else
a=a>s?(a*s/gcd(a,s)):(a*s/gcd(s,a));
}
printf("%lld\n",a);
}
}
}