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

~/algor $ cat problems/funksiya-eng-yaqin-nuqta

Closest point

Easy 1000 ms 128 MB 25%
Share

Write a function Closest(a, b, c, d): of the points $P(a; b)$ and $Q(c; d)$, it returns $1$ if $P$ is closer to the origin $O(0; 0)$, $2$ if $Q$ is closer, and $0$ if the distances are equal.

Example 1: Closest(1, 2, 3, 0) → 1 — the distance to $P$ is $\sqrt{5}$, to $Q$ it is $3$.

Example 2: Closest(4, -4, 0, 3) → 2 — the distance to $P$ is $\sqrt{32}$, to $Q$ it is $3$.

Write only the function body.

The points O, P and Q on the coordinate plane; P is closer to O

Input

One line with four integers $a$, $b$, $c$ and $d$ — the arguments of the function.

Output

The value returned by the function: $1$, $2$ or $0$.

Note

$-10^{7} \le a, b, c, d \le 10^{7}$

Examples

Input #1
1 2 3 0
Output #1
1
Input #2
4 -4 0 3
Output #2
2

Sign in to submit a solution

Signing up is free and takes a minute.