問題一覧 > 通常問題

No.3108 Luke or Bishop

レベル : / AI推定難易度 : 167 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 295
作問者 : hotman78 / テスター : kenken714 Naru820 ponjuice Nzt3
お気に入りにしたユーザー ProblemId : 12132 / 自分の提出
問題文最終更新日: 2025-04-18 00:29:27
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
CPCTF 2025 : PPC (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。