输入还是有点问题.因为要有许多组测试.
倚天照海花无数,流水高山心自知。
今天是星期六,给出参考代码.
least common multiple
#include<iostream.h>
#include<stdio.h>
#define N 1000
long mul(long m,long n)
{ long t=0,m1,n1;
long Rem;
m1=m;
n1=n;
if(m<n)
{ t=m;
m=n;
n=t;
}
while(n>0)
{ Rem = m % n;
m = n;
n = Rem;
}
t=m1/m;
t=t*n1;
return(t);
}
int main()
{
int i,n,num;
long max,a[N];
scanf("%d",&n);
while(n>0)
{
scanf("%d",&num);
max=0;
for(i=0;i<num;i++)
scanf("%ld",&a[i]);
for(i=0;i<num-1;i++)
a[i+1]=mul(a[i],a[i+1]);
max=a[num-1];
printf("%ld\n",max);
n--;
}
return(0);
}