No.3108 Luke or Bishop
Problem Statement
On the coordinate plane, you first place one piece, either a rook or a bishop, at the origin $(0,0)$.
The range of movement of each piece is as follows.
-
Rook: From the current position $(x, y)$, it can move in one move to $(x + k, y)$ or $(x, y + k)$ for any chosen real number $ k $.
-
Bishop: From the current position $(x, y)$, it can move in one move to $(x + k, y + k)$ or $(x - k, y + k)$ for any chosen real number $ k $.
Find the minimum number of moves required to move the initially placed piece to the goal position $(G_x, G_y)$, when you choose the appropriate piece.
Constraints
- $-10^9 \leq G_x \leq 10^9$
- $-10^9 \leq G_y \leq 10^9$
- All inputs are given as integers.
Input
$G_x$ $G_y$
Output
Find the minimum number of moves required to move the placed piece to the goal position $(G_x, G_y)$, when you choose the appropriate piece.
Sample
Sample 1
Input
1 1
Output
1
Sample 2
Input
2 3
Output
2
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
hotman78