杭电1019 Least Common Multiple
/********************************
* 日期:2011-2-9
* 作者:SJF
* 题号:杭电1019
* 题目:Least Common Multiple
* 结果:AC
********************************/
#include<stdio.h>
int LCM(int m,int n)
{
int dividend;//被除数
int divisor;//除数
int r;//余数
dividend=m;
divisor=n;
r=dividend%divisor;
while(r!=0)
{
dividend=divisor;
divisor=r;
r=dividend%divisor;
}
return m/divisor*n;
}
int main()
{
int N;
while(scanf("%d",&N)!=EOF)
{
int i,j;
for(i=0;i<N;i++)
{
int M,a,b,result;
scanf("%d",&M);
scanf("%d",&b);
result=LCM(b,1);
for(j=1;j<M;j++)
{
scanf("%d",&a);
result=LCM(a,result);
}
printf("%d\n",result);
}
}
return 0;
}