| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
少了哪种情况?帮忙看看我想就这两种情况吧,结果错了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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator