#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;
}
ural1753Bookshelf 三分
最新推荐文章于 2017-10-16 23:41:00 发布