Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

SOS!!!!高手 为什么会WA ?

Posted by yoahuili at 2007-11-15 12:31:33 on Problem 3002
#include<iostream.h>
int Max=1000000000;
int bei(long int m,long int n)
{int a,b,r,t;
long int sum=0,t;
if(m>n){a=m;b=n;}
  else{a=n;b=m;}
r=b;
while(r!=0)
	{r=a%b;
     a=b;
	 b=r;
	}
t=m/a;
for(int i=1;i<=n;i++)
	{sum+=t;
     if(sum>Max)return 0;
	}
return sum;
}
void main()
{int n,w;
long int p[1005],t;
cin>>n;
for(int i=1;i<=n;i++)
     {cin>>w;
        if(w==0){cout<<"0"<<endl;continue;}
        for(int j=1;j<=w;j++)
		cin>>p[j];
	if(w==1){cout<<p[1]<<endl;continue;}			       
	for(j=2,t=bei(p[1],p[2]);j<=w;j++)
		{if(!t){cout<<"More than a billion."<<endl;break;}
		 else t=bei(t,p[j]);
		}
     
       if(t)cout<<t<<endl;
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator