結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2015-07-27 22:32:04 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 127 ms / 2,000 ms |
コード長 | 785 bytes |
コンパイル時間 | 3,546 ms |
コンパイル使用メモリ | 78,156 KB |
実行使用メモリ | 54,344 KB |
最終ジャッジ日時 | 2024-10-07 21:01:31 |
合計ジャッジ時間 | 7,928 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
import java.util.*;public class walkChess{static int x;static int y;static final int[] canMove_x = {-2,-2,-1,-1,1,1,2,2};static final int[] canMove_y = {-1,1,-2,2,-2,2,-1,1};public static void main(String... args){int base_x = 0,base_y = 0;Scanner s = new Scanner(System.in);x = s.nextInt();y = s.nextInt();if(judge(0,0,0)){System.out.println("YES");}else{System.out.println("NO");}}public static boolean judge(int px,int py,int cw){int count = cw;if(px == x && py == y){return true;}else if(cw == 3){return false;}else{for(int i = 0; i < 8; i++){int after_x = px+canMove_x[i];int after_y = py+canMove_y[i];if(judge(after_x,after_y,count+1)){return true;}}return false;}}}