FZU 2095 水面高度

时间:2021-08-15 02:09:37

一共六种情况。手算即可。

#include<cstdio>
#include<cstring>
#include<cmath> int T;
double a,b,c,d,x;
double ans; int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&x);
double h=sqrt(c*c-x*x*c*c/(a*a));
double p=x*c/a;
double tmp=a*d; if(x<=h)
{
double m=a*a/sqrt(a*a-x*x);
double s1=m*x/;
double s2=a*c-m*x;
double s3=m*x/; if(tmp<=s1) ans=sqrt(tmp/s1)*x;
else if(tmp<=s1+s2) ans=(tmp-s1+m*x)/m;
else ans=x+h-sqrt((a*c-tmp)/s1)*x;
}
else
{
double m=c*c/p;
double s1=m*h/;
double s2=a*c-m*h;
double s3=m*h/; if(tmp<=s1) ans=sqrt(tmp/s1)*h;
else if(tmp<=s1+s2) ans=(tmp-s1+m*h)/m;
else ans=h+x-sqrt((a*c-tmp)/s1)*h;
} printf("%.2lf\n",ans);
}
return ;
}