Sweety

Practice makes perfect

导航

第三届山东省ACM Fruit Ninja II

Posted on 2016-05-04 15:11  蓝空  阅读(115)  评论(0编辑  收藏  举报




#include <iostream>  
#include <stdio.h>  
#include <cmath>  
using namespace std;  
  
int main()  
{  
    int T;  
    scanf("%d",&T);  
    int i;  
    for(i=1;i<=T;i++)  
    {  
        int a,b,h;  
        scanf("%d%d%d",&a,&b,&h);  
        double V;  
        V=(4.0/3)*M_PI*a*b*b;  
        if(h>=b)  
        {  
            printf("Case %d: %.3lf\n",i,V);  
        }  
        else  
        {  
            double v=M_PI*a*b*(b-h)-M_PI*(1.0*a/b)*(1.0/3)*(b*b*b-h*h*h);  
            if(V-v-v>0)  
            printf("Case %d: %.3lf\n",i,V-v);  
            else  
            printf("Case %d: %.3lf\n",i,v);  
        }  
    }  
    return 0;  
}