1 0 0 0 100 100 0 100 100 2 2 1
136.60
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps=1e-6;
struct node
{
    double x;
    double y;
}a,b,c,d,bb,dd;
double ab,cd;
double p,q,r;
double dis(node u,node v)
{
    return  sqrt(eps+(u.x-v.x)*(u.x-v.x)+(u.y-v.y)*(u.y-v.y));
}
double work(double t)
{
    dd.x=d.x+(c.x-d.x)/cd*t*q;
    dd.y=d.y+(c.y-d.y)/cd*t*q;
    return t+dis(bb,dd)/r;
}
double solve(double t)
{
     bb.x=a.x+(b.x-a.x)/ab*t*p;
     bb.y=a.y+(b.y-a.y)/ab*t*p;
    double l=0,h=cd/q,mid1,mid2;
    while(l+eps<h)
    {
        mid1=l+(h-l)/3;
        mid2=h-(h-l)/3;
        if(work(mid1)<work(mid2))
        {
            h=mid2;
        }
        else
        l=mid1;
    }
    return t+work(l);
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y);
        scanf("%lf%lf%lf%lf",&c.x,&c.y,&d.x,&d.y);
        scanf("%lf%lf%lf",&p,&q,&r);
        ab=dis(a,b);
        cd=dis(c,d);
        double l=0.0,h=ab/p,mid1,mid2;
        while(l+eps<h)
        {
            mid1=l+(h-l)/3;
            mid2=h-(h-l)/3;
            if(solve(mid1)<solve(mid2))
            h=mid2;
            else
            l=mid1;
        }
        printf("%.2f\n",solve(mid1));
    }
    return 0;
}
原文地址:http://blog.csdn.net/caduca/article/details/43484995