天天看点

Cylinder Candy ZOJ - 3866 数学 几何 积分

Edward the confectioner is making a new batch of chocolate covered candy. Each candy center is shaped as a cylinder with radius r mm and height h mm.

    The candy center needs to be covered with a uniform coat of chocolate. The uniform coat of chocolate is d mm thick.

    You are asked to calcualte the volume and the surface of the chocolate covered candy.

Input

    There are multiple test cases. The first line of input contains an integer T(≤ T≤ ) indicating the number of test cases. For each test case:

    There are three integers r, h, d in one line. (≤ r, h, d ≤ )
Output

    For each case, print the volume and surface area of the candy in one line. The relative error should be less than -
Sample Input

    
      
      

Sample Output

     
     

           

一直错在面积积分,侧面宽度不是dy,是

Cylinder Candy ZOJ - 3866 数学 几何 积分

,则面积是

Cylinder Candy ZOJ - 3866 数学 几何 积分
Cylinder Candy ZOJ - 3866 数学 几何 积分
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double Pi = acos(-);
int T;
double r,h,d,v,s,R,H;
int main()
{
    scanf("%d",&T);
    while(T--)
    {
        scanf("%lf%lf%lf",&r,&h,&d);
        R=r+d;H=h+d+d;
        v=Pi*R*R*h+*Pi*(r*r*d+*d*d*d/+Pi*r*d*d/);
        s=*Pi*R*h+*Pi*r*r+*Pi*Pi*r*d+*Pi*d*d; 
        printf("%.12lf %.12lf\n",v,s);
    }
    return ;
}