LightOJ 1062 Crossed Ladders (二分)
Posted synapse7
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LightOJ 1062 Crossed Ladders (二分)相关的知识,希望对你有一定的参考价值。
http://lightoj.com/volume_showproblem.php?problem=1062
/*0.000s,1700KB*/
#include<bits/stdc++.h>
using namespace std;
double EPS = 1e-8;
int main()
double a, b, c, j, c1, h, k, x;
int T, cas = 0;
scanf("%d", &T);
while (T--)
scanf("%lf%lf%lf", &a, &b, &c);
h = k = x = 0;
double lo = 0, hi = max(a, b);
while (fabs(lo - hi) > EPS)
x = (lo + hi) / 2;
h = sqrt(a * a - x * x);
k = sqrt(b * b - x * x);
c1 = (k * h) / (k + h);
if (fabs(c1 - c) <= EPS) break;
else if (c1 > c)lo = x + EPS;
else hi = x - EPS;
printf("Case %d: %.7f\\n", ++cas, x);
return 0;
以上是关于LightOJ 1062 Crossed Ladders (二分)的主要内容,如果未能解决你的问题,请参考以下文章
LightOJ 1062 - Crossed Ladders 基础计算几何
POJ 1692 Crossed Matchings(DP)