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

已经AC了,不过我上面的做法错在哪里?还有下面这种也是WA

Posted by Essence_me at 2005-07-30 10:50:05 on Problem 2507
In Reply To:为什么还是WA,我实在转不过来了. Posted by:Essence_me at 2005-07-30 10:35:27
#include <stdio.h>
#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)
		{
			a=(m2+m1)/2;
			h1=sqrt(x*x-a*a);
			h2=sqrt(y*y-a*a);
			c1=(h1*h2)/(h1+h2);
			if(ABS(c1-c)<0.001)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