Runner and Sniper

You give your start position and the gun's start angle and turn rate, then compute the fastest run speed at which the rotating gun still catches you.

Hard9Game theoryGeometryMathNo attempts yetTime limit2sMemory limit256 MB

Problem

You are running from an enemy. The enemy is a sniper with a laser gun, and a single hit ends the chase, so you want to know how fast you have to run to stay alive.

You and the sniper are on the xy-plane, with the x-axis pointing right and the y-axis pointing up. The plane is infinite, and nothing blocks the laser or your movement.

The sniper and the gun are at (0,0)(0, 0) and never move. The gun turns continuously at a rate of at most ω\omega degrees per unit time, clockwise or counterclockwise, and the sniper may reverse the turn at any moment. At time 00 the gun points θ\theta degrees counterclockwise from the positive direction of the x-axis.

You start at (x,y)(x, y) and may move in any direction at a speed of at most vv. You choose the value of vv yourself. You are shot exactly when the gun points at your position, so the time the laser needs to reach you is ignored. You are a point, and the laser is a half-line whose endpoint is (0,0)(0, 0).

Both you and the sniper act optimally. Find the largest speed vv for which the sniper still shoots you in finite time.

Input

One line holds four integers xx, yy, θ\theta, ω\omega separated by spaces.

  • x1000|x| \le 1000, y1000|y| \le 1000, and (x,y)(0,0)(x, y) \ne (0, 0) give your starting position.
  • 0θ<3600 \le \theta < 360 is the initial direction of the gun, measured counterclockwise from the positive x-axis in degrees.
  • 1ω1001 \le \omega \le 100 is the angle in degrees that the gun can turn per unit time.

At time 00 the gun does not point at your position.

Output

Print the largest speed vv on one line, rounded to exactly 8 digits after the decimal point, in the format printf("%.8f") produces. No test is close enough to a rounding boundary for a correct double-precision computation to change the last digit.