poj 3365(数学,分段函数)

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double PI = 3.141592653589;
int main(){
    double w,h,v1,v2,v3,v4,x;
    while(scanf("%lf%lf",&w,&h)!=EOF&&w){
        v1 = 0;v2 = 0;v3 = 0;
        if(h>=PI*w+w)v1 = PI*w*w*w/4;
        else v2 = PI*w*h*h/(4*(PI+1)*(PI+1));
        x = w/PI;
        v3 = PI/4*(x*x*h-x*x*x);
        printf("%.3lf\n",max(max(v1,v2),v3));
    }
    return 0;
}

 

posted @ 2021-08-01 20:53  智人心  阅读(38)  评论(0)    收藏  举报