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

为什么这个代码wa啊?

Posted by fengyang at 2007-09-20 06:25:02 on Problem 3002
//把变量都用_int64,不用bool y;就能过.
#include <stdio.h>
int f(int b,int a)
{
	int r;
	while(r=b%a)
	{
		b=a;
		a=r;
	}
	return a;
}
int main()
{
	int a[50],n,c,i,t,r;
	bool y;
	double s;
	scanf("%d",&c);
	while(c--)
	{
		scanf("%d",&n);
		for(i=0;i<n;i++)
			scanf("%d",a+i);
		r=1;
		y=0;
		for(i=0;i<n;i++)
		{
			t=f(r,a[i]);
			a[i]/=t;
			s=r*a[i];
			if(s>1000000000)
			{
				y=1;
				break;
			}
			r*=a[i];
		}
		if(y)printf("More than a billion.\n");
		else printf("%d\n",r);
	}
	return 0;
}

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