第一题的:
#include <stdio.h>
#include <malloc.h>typedef unsigned long UL;
UL *Lcm;
UL lcm(UL m,UL n)
{
UL t=n,m1=m,n1=n;
if(m>n)
{
t=m;
m=n;
n=t;
}
while(n%m!=0)
{
t=n;
n=m;
m=t%m;
}
return m1*n1/m;
}void l(UL *p,UL t)
{
UL n=p[0];
UL i;
for(i=1;i<=n;i++)
Lcm[t]=lcm(Lcm[t],p[i]);
printf(\"%ld\n\",Lcm[t]);
}int main()
{
UL i,j,m,n;
char g;
UL **num;
printf(\"**********INPUT***********\n\");
scanf(\"%ld\",&n);
num=(UL**)malloc(sizeof(UL*)*n);
Lcm=(UL*)malloc(sizeof(UL)*n);
for(i=0;i<n;i++)
Lcm[i]=1;
for(i=0;i<n;i++)
{
m=0;
while((g=getchar())!=' ')
{
if(g==10)
continue;
m=(g-'0')+m*10;
}
num[i]=(UL*)malloc(sizeof(UL)*(m+1));
num[i][0]=m;
for(j=1;j<=num[i][0];j++)
{
m=0;
while((g=getchar())!=' ')
{
if(g==10)
break;
m=(g-'0')+m*10;
}
num[i][j]=m;
}
}
printf(\"**********OUTPUT**********\n\");
for(i=0;i<n;i++)
l(num[i],i);
free(num);
free(Lcm);
getch();
}