The first line of the input contains an integer T (T <= 100), indicating the number of cases.
3 2 1 0.5 2 0.5 3 4 3 4
1.000 0.750 4.000
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<string.h> #include<algorithm> #include<queue> #include<stack> #include<set> #include<map> #include<vector> using namespace std; typedef long long ll; const double esp=1e-8;; double H,h,D; double cal(double x) { return D-x+H-(H-h)*D/x; } double three_devide(double l,double r) { double left=l,right=r,mid,midd; while(left+esp<right) { mid=(right+left)/2; midd=(right+mid)/2; if(cal(mid)>=cal(midd)) { right=midd; } else { left=mid; } } return cal(right); } int main() { int t; scanf("%d",&t); while(t--) { scanf("%lf%lf%lf",&H,&h,&D); double l=D-h*D/H,r=D; double ans=three_devide(l,r); printf("%0.3f\n",ans); } return 0; }