题目:
B君要用一个表面积为S的圆锥将白山云包起来。
B君希望包住的白山云体积尽量大,B君想知道体积最大可以是多少。
注意圆锥的表面积包括底面和侧面。
Input
一行一个整数,表示表面积S。(1 <= S <= 10^9)
Output
一行一个实数,表示体积。
Input示例
8
Output示例
1.504506
思路:
=\frac{1}{3}*\sqrt{t*S^{2}-2*\pi *S*t^{2}}
首先要知道圆锥表面积公司和体积公式;
面积公式:
(r是底面圆半径,l是母线长度,
,h为圆锥体的高)
![This is the rendered form of the equation. You can not edit this directly. Right click will give you the option to save the image, and in most browsers you can drag the image onto your desktop or another program.](https://i-blog.csdnimg.cn/blog_migrate/1d8fd97205f104c053fd5e8781fa6334.gif)
![This is the rendered form of the equation. You can not edit this directly. Right click will give you the option to save the image, and in most browsers you can drag the image onto your desktop or another program.](https://i-blog.csdnimg.cn/blog_migrate/88d7d69540c22cbf3eaa17fa7231c8c0.gif)
体积公式:
![This is the rendered form of the equation. You can not edit this directly. Right click will give you the option to save the image, and in most browsers you can drag the image onto your desktop or another program.](https://i-blog.csdnimg.cn/blog_migrate/64a86fa83a300e5443af0eb6ecb25420.gif)
求最大体积,首先要有S,求的h=
,然后带入到V中。
![This is the rendered form of the equation. You can not edit this directly. Right click will give you the option to save the image, and in most browsers you can drag the image onto your desktop or another program.](https://i-blog.csdnimg.cn/blog_migrate/7881b1e5a7b24d58eb64a99d4589e2df.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3ccd75c5b02691e8cf4a48a7476b998b.gif)
可见当t=b/(-2*a)时达到抛物线的最大值,将t带入原式,所以V最大为
![](https://i-blog.csdnimg.cn/blog_migrate/ae8db6fccd0896e0c2afee0e976119a7.gif)
代码:
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
#define PI 3.1415926
int main()
{
int s;
cin >> s;
double res = s*sqrt(s/(72.0*PI));
//cout << res<<endl;
printf("%.6f", res);
return 0;
}