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

谁能帮我看看这个程序错哪呢?谢谢了

Posted by queyue2004 at 2005-07-27 21:15:21 on Problem 2507
In Reply To:也是二分的,不知道哪里错了? Posted by:queyue2004 at 2005-07-27 18:06:09
> #include <iostream>
> #include <fstream>
> #include <cstdio>
> #include <cmath>
> 
> using namespace std;
> 
> int main ()
> {
> #ifndef ONLINE_JUDGE
> 	freopen ("Crossed ladders.txt","r",stdin);
> #endif
> 	double x,y,c;
> 	double max,min,mid,dis;
> 
> 	x = y = c = 0.0;
> 	while (scanf ("%lf%lf%lf",&x,&y,&c) != EOF)
> 	{
> 		x = x * x;
> 		y = y * y;
> 		if ( x > y)
> 		{
> 			max = sqrt (y - c * c) + 0.00001;
> 		}
> 		else
> 		{
> 			max = sqrt (x - c *  c) + 0.00001;
> 		}
> 		min = 0.0;
> 		while (true)
> 		{
> 			mid = (max + min) / 2.0;
> 			dis = (1.0 / sqrt (x - mid * mid) + 1.0 / sqrt ( y - mid * mid)) - 1.0 / c;
> 			if (fabs(dis) <= 0.000001)
> 			{
> 				printf ("%.3lf\n",mid);
> 				break;
> 			}
> 			else if (dis > 0)
> 			{
> 				max = mid;
> 			}
> 			else
> 			{
> 				min = mid;
> 			}
> 		}
> 		x = y = c = 0.0;
> 	}
> 
> 	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