您的位置:首页 > 其它

ural1753Bookshelf 三分

2014-09-15 20:50 381 查看
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const double eps=1e-6;
double h,H,L;
double cal(double x){//已左底角为原点,向右为x轴,书的中心为书的H/2处
return H*x/(2*sqrt(x*x+h*h))-x;
}
int main(){
scanf("%lf%lf%lf",&h,&H,&L);
double low=1e-5,high=sqrt(H*H-h*h);
while(fabs(high-low)>eps){
double lmid=(low*2+high)/3;
double rmid=(low+high*2)/3;
if(cal(lmid)>cal(rmid)) high=rmid;
else low=lmid;
}
printf("%.6f\n",cal(low));
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  tripartition