Under construction

Still being built. Things may change

Rocket Powered Hovercraft

Time limit2sMemory limit512 MB

Summary
Given a target (x, y), speed v, and turn rate w, find the minimum time for a hovercraft starting at the origin facing +X to reach the target.
Level

Medium5 of 10

Topics
Geometry, Math
Solved
No attempts yet

Problem

You are programming an autonomous rocket powered hovercraft. The vehicle can travel very fast, but turning is difficult. Because it hovers, it turns by firing directional thrusters. The thrusters turn the vehicle whether it is moving forward or standing still.

The salt flats where you test the vehicle are mapped with a 2D Cartesian grid. The hovercraft starts at (0,0)(0,0) facing the positive XX direction. Your job is to move the vehicle to another point (x,y)(x,y) on the flats.

The hovercraft has a fixed ground speed of vv miles per second and a fixed rotation rate of ww radians per second. The rockets provide enough thrust to accelerate and decelerate almost instantly. The vehicle reaches its maximum speed right away and can stop from that speed just as quickly. Rotation works the same way: it can start turning at the fixed rate instantly and stop just as quickly. It can rotate either clockwise or counter-clockwise.

You must find the minimum time needed to bring the vehicle to the target. The control program may start forward motion, stop forward motion, start rotating, and stop rotating, but each of these actions happens exactly once. Starting and stopping forward motion is independent of starting and stopping rotation.

Input

Each test case consists of exactly two lines.

The first line contains two space-separated integers xx and yy (−1000≤x,y≤1000-1000 \le x, y \le 1000, (x,y)≠(0,0)(x,y) \ne (0,0)), the target location in miles.

The second line contains two space-separated real numbers with exactly two decimal places: vv (0.01≤v≤10.000.01 \le v \le 10.00) and ww (0.01≤w≤10.000.01 \le w \le 10.00). Here vv is the fixed speed in miles per second, and ww is the fixed rotation rate in radians per second, in either direction.

Output

Print a single real number: the minimum time in seconds to bring the hovercraft from (0,0)(0,0) to (x,y)(x,y). An answer is accepted if its absolute error is within 10−310^{-3}.

Examples4

  1. Example 1

    Input
    20 0
    1.00 0.10
    
    Expected output
    20.00000000
    
  2. Example 2

    Input
    -10 10
    10.00 1.00
    
    Expected output
    3.14159265
    
  3. Example 3

    Input
    0 20
    1.00 0.10
    
    Expected output
    28.26445910
    
  4. Example 4

    Input
    -997 -3
    5.64 2.15
    
    Expected output
    177.76915187