#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
double ax,bx,ay,by,cx,cy,dx,dy;
double p,q,r;
double cal(double x1,double x2,double y1,double y2)
{
return sqrt(pow(x1-x2,2)+pow(y1-y2,2));
}
double search(double x,double y)
{
double lcdx=cx;
double lcdy=cy;
double rcdx=dx;
double rcdy=dy;
while(rcdx-lcdx>1e-5||rcdy-lcdy>1e-5)
{
double mcd1x=lcdx+(rcdx-lcdx)/3;
double mcd1y=lcdy+(rcdy-lcdy)/3;
double mcd2x=rcdx-(rcdx-lcdx)/3;
double mcd2y=rcdy-(rcdy-lcdy)/3;
if(cal(mcd1x,x,mcd1y,y)/r+cal(ax,x,ay,y)/p+cal(dx,mcd1x,dy,mcd1y)/q>=cal(mcd2x,x,mcd2y,y)/r+cal(ax,x,ay,y)/p+cal(dx,mcd2x,dy,mcd2y)/q)
{
lcdx=mcd1x;
lcdy=mcd1y;
}
else
{
rcdx=mcd2x;
rcdy=mcd2y;
}
}
return min(cal(lcdx,x,lcdy,y)/r+cal(ax,x,ay,y)/p+cal(dx,lcdx,dy,lcdy)/q,cal(rcdx,x,rcdy,y)/r+cal(ax,x,ay,y)/p+cal(dx,rcdx,dy,rcdy)/q);
}
int main()
{
scanf("%lf%lf%lf%lf",&ax,&ay,&bx,&by);
scanf("%lf%lf%lf%lf",&cx,&cy,&dx,&dy);
scanf("%lf%lf%lf",&p,&q,&r);
double labx=ax;
double laby=ay;
double rabx=bx;
double raby=by;
while(rabx-labx>1e-5||raby-laby>1e-5)
{
double mab1x=labx+(rabx-labx)/3;
double mab1y=laby+(raby-laby)/3;
double mab2x=rabx-(rabx-labx)/3;
double mab2y=raby-(raby-laby)/3;
if(search(mab1x,mab1y)>=search(mab2x,mab2y))
{
labx=mab1x;
laby=mab1y;
}
else
{
rabx=mab2x;
raby=mab2y;
}
}
printf("%.2lf\n",min(search(labx,laby),search(rabx,raby)));
return 0;
}
1439:【SCOI2010】传送带
最新推荐文章于 2022-01-21 15:13:11 发布