ZOJ 3866 Cylinder Candy


テーマリンク:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5478
タイトル:
Cylinderキャンディー
Time Limit: 2 Seconds     
メモリLimit: 65536 KB     
Special Jundge
Edward the confectior is making a new batch of chocollate covered candy.Each candyセンターis shopd as a cylinder with radius r mm and height h mm.
The candyセンターneeds to be covered with a uniform coat of chocollate.The unif orm coat of chocolate is d mm thick.
You are asked to calcualte the volume and the surface of the chocollate covered candy.
Input
The re 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:
The re re three integers r, h, d in one line.(1≦1≦ r, h, d ≤100)
Output
For each case,print the volume and surface are of the candy in one line.The relative error shound be less than 10-8.
Sample Input
2
1 1 1
1 3 5
Sample Output
32.907950527415 51.155135338077
1141.046818749128 532.235830206285
正解:
模式図図形はx軸を回る回転体です.
ZOJ 3866 Cylinder Candy_第1张图片
導出プロセス:
    体積:3部です
1.上下の中間の円柱を除く. V 1=pi*(d+r)*(d+r)*h
2.上の二つの円柱  V 2=2*pi*r*d
3.上下二つの丸のようなもの.
    まず、円環の面積を計算してから、ポイントが0からdまではこのリングの体積です.
    各層の円環の面積はS=pi*((sqrt(d-x*)+r)^2)-pi*(r*r)=)S=pi*(d*d-x*x+2*r*sqrt(d*d-x*x)であり、大円が小さくなります.
    その後,積分は0からd,dxまでであった.V 3=2*(0-d) (S)dx  
    積しにくいのはルート番号の下のdの二乗からxの二乗を減算します.数式を利用して∫(√a*x*)dx=x/2*(√a*x*)+a*a/2*arcsin(x/a)+C(Cは定数で、ここでは不要です.主に隣にポイント表がありますか?)
だからVolume=V 1+V 2+V 3です.
ZOJ 3866 Cylinder Candy_第2张图片
表面積:
3つの部分に分けて計算します.
1.上下2つの円 S 1=2*pi*r*r
2.隣の円柱側の面積 S 2=2*pi*(r+d)*h
3.類の円環物の側面面積
ZOJ 3866 Cylinder Candy_第3张图片
上記の公式を利用して、このように図を作ることができます.
ZOJ 3866 Cylinder Candy_第4张图片
x=x,y=sqrt(d*d-x*)+r
回転体側面積をS 3=2*pi∫(0からd)f(x)*sqrt(1+f'(x)^2)dxに代入すれば得られます. ∫dx/(sqrt(a*a-x*)=arcsin(x/a)+C(Cはここでは必要ありません)を使用します.
S=S 1+S 2+2*S 3
ちょっと乱れていますが、許してください.
総括:試合の時、方法は正しくて、表の面積の式子はすべて代わって正しいです.つまり2*piのこの項は後に配属することを忘れて、見たところ平穏な心理状態と整然としている草稿の紙はまだとても重要です!
コード:
#include <iostream>
#include <cmath> 
#include <iomanip>
#define pi 4*atan(1.0) 
using namespace std;
int main()
{
	int t,r,h,d;
    cin>>t;
    while(t--)
    {
    	cin>>r>>h>>d;
    	cout<<fixed<<setprecision(12)<<2*(2*d*d*d/3.0*pi+r*d*d*pi*pi/2)+pi*((r+d)*(r+d))*(h)+pi*(r*r)*2*d<<" ";
    	cout<<fixed<<setprecision(12)<<2*(pi*pi*d*r+2*pi*d*d)+2*pi*r*r+2*pi*(r+d)*h<<endl;
    }
	return 0;
}