#include <iostream>#include<iomanip>#include <cstdio>#include <cmath>using namespacestd;#define eps 1e-8const double pi=acos(-1.0);double S;double cal(double x){ return(1.0/3.0)*x*sqrt(S*(S-(2*pi*x*x)));}int main(){ while(cin>>S) { double left=0.1,right=sqrt(S/2.0/pi); while(right-left>eps) { double middle=(left+right)/2; double middleright=(middle+right)/2; if(cal(middle)>cal(middleright)) right=middleright; else left=middle; } cout<<setPRecision(2)<<fixed<<cal(left)<<endl; cout<<setprecision(2)<<fixed<<sqrt(S*(S-2*pi*left*left))/pi/left<<endl; cout<<setprecision(2)<<fixed<<left<<endl; } return 0;}
本题的解题方向在于得出圆锥表面积和体积的关系,得到R的上限,并借此通过二分法求得使圆锥体积最大的半径,进而得解,输出时要注意格式。
新闻热点
疑难解答