ZOJ 1797这真的不是水题

//错了2次委屈  本以为没考虑 公倍数是0的结果

//_int32 是long而不是int 哦

#include<stdio.h>

long f(long a,long b)
{
long temp,r;
if(a<b)
{
temp=a;
a=b;
b=temp;
}
r=a%b;
while(r!=0)
{
a=b;
b=r;
r=a%b;
}
return  b;
}
int main()
{
    long n,i,s,c,t;
    scanf("%ld",&n);
    while(n-->0)
    {
    scanf("%ld",&s);
    if(s!=0)
    scanf("%ld",&t);
    else
    t=0;
    for(i=2;i<=s;i++)
    {
    scanf("%ld",&c);
    if(t==0)
    continue;
if(c==0)
    t=0;
    else
    t=(t*c)/f(t,c);
   }
    printf("%ld\n",t);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/u013517141/article/details/23194301
ZOJ