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 sparkling at 2007-09-01 22:23:33 on Problem 3365
我想就这两种情况吧,结果错了N次了,帮忙看看吧,不知道少考虑了哪种情况。
1. W作圆周,2.W作高

#include <stdio.h>
#include <math.h>
int main()
{
	double PI = acos(0)*2.0f;
	int W, H;
	double v, r, t;
	while(scanf("%d %d", &W, &H) == 2){
		if(W > H){
			int tmp = W;
			W = H;
			H = tmp;
		}
		if(!W && !H) break;
		// 1. v = pi*r*r(H - 2*r), r = w/(2*pi)
		r = W/(2*PI);
		v = PI*r*r*(H - 2*r);
		// 2. h = W
		r = H/(2*PI + 2);
		if(2*r > W) r = W/2;
		t = PI*r*r*W;
		if(v < t) v = t;
		printf("%0.3f\n", v);
	}
	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