36 lines
527 B
C++
36 lines
527 B
C++
#include <iostream>
|
|
#include<cstdio>
|
|
#include<algorithm>
|
|
#include <cmath>
|
|
using namespace std;
|
|
const double eps= 1e-5;
|
|
double H,h,D;
|
|
double f(double d)
|
|
{
|
|
return D-d+H-(H-h)*D/d;
|
|
// return D-d+h-(H-h)*(D-d)/d;
|
|
}
|
|
double sanfen(double l,double r)
|
|
{
|
|
double mid,midr,ans;
|
|
while(fabs(r-l)>eps)
|
|
{
|
|
mid=(l+r)/2;
|
|
midr=(mid+r)/2;
|
|
if(f(mid)<f(midr))l=mid;
|
|
else r=midr;
|
|
}
|
|
return f(l);
|
|
}
|
|
int main()
|
|
{
|
|
int t;
|
|
scanf("%d",&t);
|
|
while(t--)
|
|
{
|
|
scanf("%lf%lf%lf",&H,&h,&D);
|
|
printf("%.3lf\n",sanfen(D-D*h/H,D));
|
|
}
|
|
return 0;
|
|
}
|