# Bzoj1857 [scoi2010]传送带

## 三分套三分，玄学套玄学

Posted by yjjr's blog on March 7, 2018

# 题目

## Description

lxhgww在AB上的移动速度为P，在CD上的移动速度为Q，在平面上的移动速度R。

## Sample Input

0 0 0 100
100 0 100 100
2 2 1


## Sample Output

136.60


1<=P，Q，R<=10

# code

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
#define eps 1e-3
using namespace std;
{
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int ax,ay,bx,by,cx,cy,dx,dy,p,q,r;
inline double dis(double x1,double y1,double x2,double y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double cal(double x,double y){
double lx=cx,ly=cy,rx=dx,ry=dy,x1,y1,x2,y2,t1,t2;
while(fabs(rx-lx)>eps||fabs(ry-ly)>eps){
x1=lx+(rx-lx)/3,y1=ly+(ry-ly)/3;
x2=lx+(rx-lx)/3*2,y2=ly+(ry-ly)/3*2;
t1=dis(ax,ay,x,y)/p+dis(x,y,x1,y1)/r+dis(x1,y1,dx,dy)/q;
t2=dis(ax,ay,x,y)/p+dis(x,y,x2,y2)/r+dis(x2,y2,dx,dy)/q;
if(t1>t2)lx=x1,ly=y1;else rx=x2,ry=y2;
}
return dis(ax,ay,x,y)/p+dis(x,y,lx,ly)/r+dis(lx,ly,dx,dy)/q;
}
int main()
{