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(1≤ T≤ 1000) indicating the number of test cases. For each test case:
There are three integers r, h, d in one line. (1≤ r, h, d ≤ 100)
Output
For each case, print the volume and surface area of the candy in one line. The relative error should be less than 10-8.
Sample Input
2 1 1 1 1 3 5
Sample Output
32.907950527415 51.155135338077 1141.046818749128 532.235830206285
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3866
几何题,加了外层之后可以看作是上下两个旋转体加上中间的圆柱体(半径为r+d),用积分算一下得到公式。
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <string> 5 #include <iomanip> 6 #include <cmath> 7 using namespace std; 8 #define pai acos(-1.0) 9 int T; 10 double r, h, d; 11 int main(){ 12 scanf("%d", &T); 13 while(T--){ 14 scanf("%lf%lf%lf", &r, &h, &d); 15 double v, area; 16 v = (pai*r*d*d*asin(1.0) + pai*(2.0/3.0*d*d*d + r*r*d))*2 + (r+d)*(r+d)*pai*h; 17 area = 2*(2*pai*d*d + 2*pai*r*d*asin(1.0)) + 2*pai*r*r + 2*pai*(r+d)*h; 18 printf("%.12lf %.12lf ", v, area); 19 } 20 21 return 0; 22 }