本文搬运自本人初中博客园博客,若图片加载不出来,可到原文查看:https://www.cnblogs.com/zhangtingxi/p/15693858.html

题目链接

题目

在一个 22 维平面上有两条传送带,每一条传送带可以看成是一条线段。两条传送带分别为线段 AB\text{AB} 和线段 CD\text{CD}。lxhgww 在 AB\text{AB} 上的移动速度为 PP,在 CD\text{CD} 上的移动速度为 QQ,在平面上的移动速度 RR。现在 lxhgww 想从 A\text A 点走到 D\text D 点,他想知道最少需要走多长时间。

思路

三分套三分。

现在AB上三分一个点,再在CD上三分一个点,易证符合单调性。

求距离需要用到一些数学知识。

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include<bits/stdc++.h>
using namespace std;
//#define int long long
inline int read(){int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;
ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+
(x<<3)+(ch^48);ch=getchar();}return x*f;}
//#define M
//#define mo
//#define N
int n, m, i, j, k;
double ax, ay, bx, by, cx, cy, dx, dy, p, q, r;

double pingfa(double x)
{
return x*x;
}

double go(double lx, double ly, double rx, double ry, double speed)
{
double s=sqrt(pingfa(rx-lx)+pingfa(ry-ly));
return s/speed;
}

double second_three_mid(double lstlx, double lstly)
{
double lx, ly, rx, ry, tx, ty, nlx, nly, nrx, nry;
double lans, rans;
lx=cx; ly=cy; rx=dx; ry=dy;
while(abs(rx-lx)>1e-12||abs(ry-ly)>1e-12)
{

tx=(rx-lx)/3; ty=(ry-ly)/3;
nlx=lx+tx; nly=ly+ty;
nrx=rx-tx; nry=ry-ty;
lans=go(lstlx, lstly, nlx, nly, q)+go(nlx, nly, dx, dy, r);
rans=go(lstlx, lstly, nrx, nry, q)+go(nrx, nry, dx, dy, r);
// printf("> %lf %lf %lf %lf %lf %lf\n", lx, ly, rx, ry, lans, rans);
if(lans<rans) rx=nrx, ry=nry;
else lx=nlx, ly=nly;
}
// printf("======= %lf %lf========", go(lstlx, lstly, lx, ly, q), go(lx, ly, dx, dy, r));
return go(lstlx, lstly, lx, ly, q)+go(lx, ly, dx, dy, r);
}

double first_three_mid()
{
double lx, ly, rx, ry, tx, ty, nlx, nly, nrx, nry;
double lans, rans;
lx=ax; ly=ay; rx=bx; ry=by;
while(abs(rx-lx)>1e-12||abs(ry-ly)>1e-12)
{
// printf("> %lf %lf %lf %lf\n", lx, ly, rx, ry);
tx=(rx-lx)/3; ty=(ry-ly)/3;
nlx=lx+tx; nly=ly+ty;
nrx=rx-tx; nry=ry-ty;
lans=go(ax, ay, nlx, nly, p)+second_three_mid(nlx, nly);
rans=go(ax, ay, nrx, nry, p)+second_three_mid(nrx, nry);
// printf("\n%lf %lf %lf %lf %lf\n", nlx, nly, go(ax, ay, nlx, nly, p), second_three_mid(nlx, nly), lans);
// printf("\n%lf %lf %lf %lf %lf\n", nrx, nry, go(ax, ay, nrx, nry, p), second_three_mid(nrx, nry), rans);
if(lans<rans) rx=nrx, ry=nry/*, printf("right\n")*/;
else lx=nlx, ly=nly;
}
// printf("--- %lf %lf\n", go(ax, ay, lx, ly, p), second_three_mid(lx, ly));
return go(ax, ay, lx, ly, p)+second_three_mid(lx, ly);
}

signed main()
{
// freopen("tiaoshi.in", "r", stdin);
// freopen("tiaoshi.out", "w", stdout);
ax=double(read()); ay=double(read());
bx=double(read()); by=double(read());
cx=double(read()); cy=double(read());
dx=double(read()); dy=double(read());
if(ax==dx&&ay==dy) return printf("0.00"), 0;
p=double(read()); r=double(read()); q=double(read());
printf("%.2lf", first_three_mid());
return 0;
}