题目

ZOJ-3203-三分模板ZOJ-3203-三分模板

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define en '\n'
#define eps 1e-10
using namespace std;
typedef double du;
const int INF=1e9,N=1e4+5;
du H,h,D;
du work(du x)
{
    return D*(H-h)/(x-H)+x+D;
}
int main()
{
    int T;scanf("%d",&T);
    while(T--)
    {
        scanf("%lf%lf%lf",&H,&h,&D);
        du l=0,r=h,m1,m2,ans;
        while(r-l>eps)
        {
            m1=(l+r)/2,m2=(m1+r)/2;
            if((ans=work(m1))>work(m2))
                r=m2;
            else
                l=m1;
        }
        printf("%.3f\n",ans);
    }
}

相关文章:

  • 2021-08-18
  • 2021-08-24
  • 2022-02-28
  • 2022-12-23
  • 2021-07-30
  • 2022-02-28
  • 2021-07-15
猜你喜欢
  • 2021-08-19
  • 2022-03-04
  • 2022-02-15
  • 2021-12-02
  • 2022-12-23
  • 2021-07-05
相关资源
相似解决方案