cf590B Chip 'n Dale Rescue Rangers

B. Chip 'n Dale Rescue Rangers
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

A team of furry rescue rangers was sitting idle in their hollow tree when suddenly they received a signal of distress. In a few moments they were ready, and the dirigible of the rescue chipmunks hit the road.

We assume that the action takes place on a Cartesian plane. The headquarters of the rescuers is located at point (x1, y1), and the distress signal came from the point (x2, y2).

Due to Gadget's engineering talent, the rescuers' dirigible can instantly change its current velocity and direction of movement at any moment and as many times as needed. The only limitation is: the speed of the aircraft relative to the air can not exceed  meters per second.

Of course, Gadget is a true rescuer and wants to reach the destination as soon as possible. The matter is complicated by the fact that the wind is blowing in the air and it affects the movement of the dirigible. According to the weather forecast, the wind will be defined by the vector (vx, vy) for the nearest t seconds, and then will change to (wx, wy). These vectors give both the direction and velocity of the wind. Formally, if a dirigible is located at the point (x, y), while its own velocity relative to the air is equal to zero and the wind (ux, uy) is blowing, then after  seconds the new position of the dirigible will be .

Gadget is busy piloting the aircraft, so she asked Chip to calculate how long will it take them to reach the destination if they fly optimally. He coped with the task easily, but Dale is convinced that Chip has given the random value, aiming only not to lose the face in front of Gadget. Dale has asked you to find the right answer.

It is guaranteed that the speed of the wind at any moment of time is strictly less than the maximum possible speed of the airship relative to the air.

Input

The first line of the input contains four integers x1, y1, x2, y2 (|x1|,  |y1|,  |x2|,  |y2| ≤ 10 000) — the coordinates of the rescuers' headquarters and the point, where signal of the distress came from, respectively.

The second line contains two integers  and t (0 < v, t ≤ 1000), which are denoting the maximum speed of the chipmunk dirigible relative to the air and the moment of time when the wind changes according to the weather forecast, respectively.

Next follow one per line two pairs of integer (vx, vy) and (wx, wy), describing the wind for the first t seconds and the wind that will blow at all the remaining time, respectively. It is guaranteed that  and .

Output

Print a single real value — the minimum time the rescuers need to get to point (x2, y2). You answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

Sample test(s)
input
0 0 5 5
3 2
-1 -1
-1 0
output
3.729935587093555327
input
0 0 0 1000
100 1000
-50 0
50 0
output
11.547005383792516398

如果学过一点物理,你就会知道运动具有独立性,那么飞艇的运动可以拆成驱动运动和风力运动
二分一个答案,很容易判断解是否可行
 1 #include<set>
 2 #include<map>
 3 #include<ctime>
 4 #include<deque>
 5 #include<queue>
 6 #include<bitset>
 7 #include<cstdio>
 8 #include<cstdlib>
 9 #include<cstring>
10 #include<iostream>
11 #include<algorithm>
12 #define LL long long
13 #define inf 0x7fffffff
14 #define pa pair<int,int>
15 #define pi 3.1415926535897932384626433832795028841971
16 #define eps 1e-8
17 using namespace std;
18 inline LL read()
19 {
20     LL x=0,f=1;char ch=getchar();
21     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
22     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
23     return x*f;
24 }
25 double x1,x2,y1,y2,x,y,l,r,ans,vm,t,sumx,sumy;
26 int tot;
27 inline bool jud(double mid)
28 {
29     sumx=x;sumy=y;
30     if (mid<=t)sumx-=mid*x1,sumy-=mid*y1;
31     else sumx-=t*x1+(mid-t)*x2,sumy-=t*y1+(mid-t)*y2;
32     return mid*mid*vm*vm>=sumx*sumx+sumy*sumy;
33 }
34 int main()
35 {
36     scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);x=x2-x1;y=y2-y1;
37     scanf("%lf%lf",&vm,&t);
38     scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
39     tot--;
40     l=0;r=100000000;
41     while (l+eps<r)
42     {
43         double mid=(l+r)/2;
44         if(jud(mid)){ans=mid;r=mid;}
45         else l=mid;
46     }
47     printf("%.7lf
",ans);
48     return 0;
49 }
cf590B
——by zhber,转载请注明来源
原文地址:https://www.cnblogs.com/zhber/p/4926563.html