Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/begin-nuqtadan-togri-chiziqqacha

Distance from a point to a line

Medium 1000 ms 64 MB 37%
Share

A line $a * x + b * y + c = 0$ and a point $M(x_{0}; y_{0})$ on the plane are given. Find the shortest distance $d$ from the point to the line (the length of the perpendicular); $|z|$ is the absolute value of a number:

$$d = \frac{|a * x_{0} + b * y_{0} + c|}{\sqrt{a^{2} + b^{2}}}$$

A line and point M on the coordinate plane; the perpendicular d dropped from M to the line

Input

The first line has three integers: $a$, $b$ and $c$. The second line has two integers: $x_{0}$ and $y_{0}$.

Output

One number — $d$, with exactly 3 digits after the decimal point (for example, 2.000).

Note

$-1000 \le a, b, c, x_{0}, y_{0} \le 1000$
$a$ and $b$ are not both zero.

Examples

Input #1
3 4 -10
0 0
Output #1
2.000
Input #2
1 -1 0
2 2
Output #2
0.000

Sign in to submit a solution

Signing up is free and takes a minute.