cho.sh
Notes
Loading...

Going Home

Time limit

2s

Memory limit

128 MB

Problem

Eunjin is currently at coordinate (X, Y), and her home is at the origin (0, 0). She wants to get home as quickly as possible.

There are two ways to move.

  • Walk: move distance 1 in 1 second.
  • Jump: spend T seconds to move exactly distance D in a straight line.

Each jump is straight, and a single jump must have length exactly D. Walking and jumping may be used in any order and any combination. Find the minimum time needed to reach home.

Input

The first line contains four integers X Y D T, separated by spaces.

Output

Print the minimum time needed to reach home. An absolute or relative error of at most 10^-9 is accepted.

Constraints

  • 1 <= X, Y <= 1000
  • 1 <= D, T <= 10000