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 Essence_me at 2005-07-30 10:35:27 on Problem 2507
include <math.h>
#define ABS(x) (((x)<0)?(-(x)):((x)))

void main()
{
	float m1,m2,a,x,y,c;
	double h1,h2,c1;
	while(scanf("%f",&x)==1)
	{
		if(scanf("%f",&y)!=1)break;
		if(scanf("%f",&c)!=1)break;
		m1=0;
		m2=(x<y)?(x):(y);
		
		while(1)
		{
			if(ABS(m1-m2)<0.001)
			{
				a=m1;
				break;
			}
			a=(m2+m1)/2;
			h1=sqrt(x*x-a*a);
			h2=sqrt(y*y-a*a);
			c1=(h1*h2)/(h1+h2);
			if(c1==c)break;
				else if(c<c1)m1=a;
					else m2=a;

		}
		printf("%.3f\n",a);
	}
}


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