No.240 Knight's Walk
タグ : / 解いたユーザー数 403
作問者 :
nmnmnmnmnmnmnm
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もしくは右上の雲マークをクリックしてアカウントを作成してください。