本次问题需要进行两次三分,同时需要有效划归三分的结点,代码参考上一个题解的,仅为自己学习所用

#include <bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)

struct node{
    double x, y;
}a, b, c, d, e, f;
int p, q, r;
const double eps = 1e-4;

double dis(node a, node b){
    return sqrt(eps + (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

double check1(double x) {
    f = { c.x + x / dis(c,d) * (d.x - c.x),c.y + x / dis(c,d) * (d.y - c.y) };
    return dis(e, f) / r + (dis(c, d) - x) / q;
}

double check(double x) {
    e = { a.x + x / dis(a,b) * (b.x - a.x),a.y + x / dis(a,b) * (b.y - a.y) };
    double l = 0, r = dis(c, d);
    for (int i = 1; i <= 1000; i++) {
        double lm = l + (r - l) / 3, rm = r - (r - l) / 3;
        if (check1(lm) >= check1(rm))l = lm;
        else r = rm;
    }
    return check1(l) + x / p;
}

int main(){
    cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y;
    cin >> p >> q >> r;
    double l = 0, r = dis(a, b);
    for (int i = 1; i <= 1000; i++) {
        double lm = l + (r - l) / 3, rm = r - (r - l) / 3;
        if (check(lm) >= check(rm))l = lm;
        else r = rm;
    }
    printf("%.2f", check(l));
    return 0;
}