eolymp
bolt
Try our new interface for solving problems
Problems

Expanding Lake

Expanding Lake

You’ve been walking around your garden when rain started. At first, you were feeling relieved because it was the first rain in two months. But suddenly you’ve realized that this is not just a normal rain, but the all-drowning rain the news were talking about. So now you need to get home \textit{fast}. Imagine your garden as an infinite plane. You are at point (\textbf{x_0}, \textbf{y_0}) on this plane, while your home is at point (\textbf{0}, \textbf{0}). You can move with speed \textbf{v_0}. Easy: \includegraphics{https://static.e-olymp.com/content/c4/c4a1bf4d2855dfca430736036c7240eecbb1d133.jpg} you might think. But there’s also a dreadful lake in your garden. It is a circle centered at (\textbf{x_1}, \textbf{y_1}) and radius \textbf{r_1}. Moveover, because of the rain, it is expanding with speed \textbf{v_1}, so its radius after time \textbf{t} is equal to \textbf{r_1} + \textbf{v_1t} (its center doesn’t move). You can’t go into the lake as you’re suddenly very afraid of water. It’s \textbf{OK} for you to stand on the border of the lake. Is it possible for you to get home? If yes, what is the minimum time required to do that? \InputFile The first line of the input file contains three integers \textbf{x_0}, \textbf{y_0} and \textbf{v_0}. \textbf{x_0^2} + \textbf{y_0^2} > \textbf{0}, \textbf{-1000} ≤ \textbf{x_0}, \textbf{y_0} ≤ \textbf{1000}, \textbf{1} ≤ \textbf{v_0} ≤ \textbf{1000}. The second line of the input file contains four integers \textbf{x_1}, \textbf{y_1}, \textbf{r_1} and \textbf{v_1}, \textbf{x_1^2} + \textbf{y_1^2} > \textbf{r_1^2}, \textbf{-1000} ≤ \textbf{x_1}, \textbf{y_1} ≤ \textbf{1000}, \textbf{1} ≤ \textbf{r_1}, \textbf{v_1} ≤ \textbf{1000}, (\textbf{x_0} - \textbf{x_1})^2 + (\textbf{y_0} - \textbf{y_1})\textbf{^2} > \textbf{r_1^2}. It is guaranteed that in case it’s possible to get home, it would still be possible when the initial radius of the lake is \textbf{r_1} + \textbf{10^\{-3\}}; in case it’s impossible to get home, it would still be impossible when the initial radius of the lake is \textbf{r_1} - \textbf{10^\{-3\}}. \OutputFile Output one floating-point number denoting the minimum time required to get home. Your answer will be considered correct, if it’s within \textbf{10^\{-9\}} relative or absolute error of the correct one. In case you can’t get home, output \textbf{-1}.
Time limit 2 seconds
Memory limit 256 MiB
Input example #1
10 0 3
7 0 1 1
Output example #1
3.753280475952816
Author Peter Mitrichev
Source Winter School, Kharkov, 2011, Day 8