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 smilezhen at 2005-08-31 21:36:02 on Problem 2507
#include <iostream.h>
#include <stdio.h>
#include <math.h>

int main(void){
	double x, y, c, m, n1, n2, h1, h2, c1;
	while(cin >> x >> y >> c){
		c1 = 0;
		if(fabs(x-y)<0.00001){
			printf("%.3lf\n",(2*sqrt((x/2)*(x/2) - c*c)));
		}else if(c == 0){
			if(x <= y)
				printf("%.3lf\n",x);
			else 
				printf("%.3lf\n",y);
		}else{
			n1 = 0;
			n2 = 1;
			m = (n1 + n2)/2;
			while(1){
				h1 = sqrt(x*x - (c/m)*(c/m));
				h2 = sqrt(y*y - (c/(1-m))*(c/(1-m)));
				if(fabs(h1 - h2) < 0.00001) break;
				else{
					if(h1>h2){
						n2 = m;
						m = (m+n1)/2;
					}
					if(h1 <h2){
						n1 = m;
						m = (m+n2)/2;
					}
				}
			}
			printf("%.3lf\n",(h1 +h2)/2+0.0005);
		}
	}
	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