AcWing 1510. 楼梯
原题链接
简单
作者:
Value
,
2020-04-25 11:10:36
,
所有人可见
,
阅读 608
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
double x, y, c;
bool check(double t){
double hx = sqrt(x * x - t * t);
double hy = sqrt(y * y - t * t);
double hc = (hx * hy) / (hx + hy);
if(hc >= c) return true;
return false;
}
int main(){
cin >> x >> y >> c;
double l = 0, r = 3000;
double mid;
while(r - l >= 1e-4){
mid = (l + r) / 2;
if(check(mid)) l = mid;
else r = mid;
}
printf("%.3lf", l);
return 0;
}