ZOJ 3866 Cylinder Candy

來源:互聯網
上載者:User

標籤:

Cylinder CandyTime Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge

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
21 1 11 3 5
Sample Output
32.907950527415 51.1551353380771141.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\n", v, area);19     }20     21     return 0;22 }

 

ZOJ 3866 Cylinder Candy

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.