問題一覧 > 通常問題

No.240 Knight's Walk

レベル : / AI推定難易度 : 147 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 403
作問者 : nmnmnmnmnmnmnm
お気に入りにしたユーザー ProblemId : 303 / 自分の提出
問題文最終更新日: 2026-06-28 19:25:20
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
yukicoder contest 114 (順位表) の他の問題:

Problem Statement

A chess knight takes a walk on an infinitely large XY coordinate plane.
One move in the manner of a knight counts as 1 step.
Since this is just a walk, the limit is at most 3 steps.
Determine whether the knight, starting from (0,0) on the XY coordinate plane, can reach the target coordinates within 3 steps.

※A chess knight is a piece that, when its current position is (x,y), can move in one move to any of the 8 positions (x-2,y-1),(x-2,y+1),(x-1,y-2),(x-1,y+2),(x+1,y-2),(x+1,y+2),(x+2,y-1),(x+2,y+1).

Input

$X$ $Y$

The values of the target coordinates (X,Y) on the XY coordinate plane are given. $-1000000000 \le X,Y \le 1000000000$.

Output

If the move is possible, output in one line:

YES


If the move is not possible, output in one line:

NO

Sample

Sample 1
Input
1 2
Output
YES

It can be reached in 1 step.

Sample 2
Input
5 -4
Output
YES

It can be reached in exactly 3 steps.

Sample 3
Input
100 100
Output
NO

It cannot be reached within 3 steps.

Sample 4
Input
0 0
Output
YES

It can be reached without moving a single step.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。