分类: C/C++
2009-05-05 22:51:54
Problem : Judge Status : Accepted
RunId : 821180 Language : C++ Author :
Problem Description:
Codes:
#include
using namespace
int LCM(long int a,long int b)
{
long int temp1=a;
long int temp2=b;
while(temp2!=0)
{
long int temp=temp1%temp2;
temp1=temp2;
temp2=temp;
}
return a/temp1*b;
}
int main()
{
int N,i,num;
long int a,b;
while(cin>>num)
{
while(cin>>N)
{
cin>>a;
for(i=0;i<N-1;i++)
{
cin>>b;
a=LCM(a,b);
}
cout<<a<<endl;
}
}
return 0;
}
chinaunix网友2009-05-05 23:08:04
你那个代码和我的有差吗?我还以为出了欧几里德还有什么新的算法类!靠, 原来是耍我的...虽然不是很赞同动不动就贴代码,不过我想这题也没怎么有人看的,你注意点,下次不要再耍我了哦! 还有你的函数写的...怎么每次进去都long一个阿?浪费空间啊?