# cf591d

#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

#define d(x) x

#define zero(x) (((x)>0?(x):-(x))<eps)
#define eps 1.0E-8
#define MAX_POINT_NUM 0

int double_cmp(double a)
{
if (zero(a))
return 0;
return a > 0 ? 1 : -1;
}

struct Point
{
double    x,y;
Point()
{}
Point(double x, double y):x(x), y(y)
{}
Point operator - (Point &a)
{
return Point(x - a.x, y - a.y);
}
bool operator <(const Point &a)const
{
return atan2(y, x) < atan2(a.y, a.x);
}
bool operator == (const Point &a) const
{
return x == a.x && y == a.y;
}
};

double point_dist(Point a)
{
return sqrt(a.x * a.x + a.y * a.y);
}

double point_dist(Point a, Point b)
{
return point_dist(a - b);
}

double dot_product(Point a, Point b)
{
return a.x * b.x + a.y * b.y;
}

double dot_product(Point p0, Point p1, Point p2)
{
return dot_product(p1 - p0, p2 - p0);
}

Point s, e;
Point wind1;
Point wind2;
double v, t;

void input()
{
int x, y;
scanf("%d%d", &x, &y);
s = Point(x, y);
scanf("%d%d", &x, &y);
e = Point(x, y) - s;
s = Point(0, 0);
scanf("%lf%lf", &v, &t);
scanf("%d%d", &x, &y);
wind1 = Point(x, y);
scanf("%d%d", &x, &y);
wind2 = Point(x, y);

}

bool ok(double a)
{
double t1 = min(a, t);
double t2 = max(a - t, 0.0);
Point by_wind = Point(t1 * wind1.x + t2 * wind2.x, t1 * wind1.y + t2 * wind2.y);
double dist = point_dist(by_wind - e);
return double_cmp(dist - v * a) <= 0;
}

double binary_search(double l, double r)
{
for (int i = 0; i < 400; i++)
{
if (double_cmp(l - r) == 0)
break;
double mid = (l + r) / 2;
if (ok(mid))
{
r = mid;
}else
{
l = mid;
}
}
return l;
}

int main()
{
input();
printf("%.18f\n", binary_search(0, 1e9));
return 0;
}
View Code

posted @ 2016-01-19 02:20  金海峰  阅读(217)  评论(0编辑  收藏