結果

問題 No.240 ナイト散歩
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-12-12 01:41:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 761 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 74,236 KB
実行使用メモリ 41,752 KB
最終ジャッジ日時 2024-04-16 19:45:06
合計ジャッジ時間 7,611 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
41,548 KB
testcase_01 AC 130 ms
41,636 KB
testcase_02 AC 132 ms
41,356 KB
testcase_03 AC 131 ms
41,316 KB
testcase_04 AC 133 ms
41,160 KB
testcase_05 AC 119 ms
41,640 KB
testcase_06 AC 131 ms
41,508 KB
testcase_07 AC 130 ms
41,452 KB
testcase_08 AC 134 ms
41,428 KB
testcase_09 AC 134 ms
41,644 KB
testcase_10 AC 133 ms
41,188 KB
testcase_11 AC 132 ms
41,620 KB
testcase_12 AC 131 ms
41,508 KB
testcase_13 AC 131 ms
41,232 KB
testcase_14 AC 131 ms
41,732 KB
testcase_15 AC 133 ms
41,628 KB
testcase_16 AC 133 ms
41,372 KB
testcase_17 AC 133 ms
41,424 KB
testcase_18 AC 134 ms
41,436 KB
testcase_19 AC 130 ms
41,180 KB
testcase_20 AC 133 ms
41,416 KB
testcase_21 AC 134 ms
41,420 KB
testcase_22 AC 135 ms
41,500 KB
testcase_23 AC 132 ms
41,632 KB
testcase_24 AC 133 ms
41,264 KB
testcase_25 AC 134 ms
41,436 KB
testcase_26 AC 134 ms
41,568 KB
testcase_27 AC 134 ms
41,588 KB
testcase_28 AC 133 ms
41,504 KB
testcase_29 AC 133 ms
41,460 KB
testcase_30 AC 133 ms
41,588 KB
testcase_31 AC 134 ms
41,752 KB
testcase_32 AC 136 ms
41,508 KB
testcase_33 AC 133 ms
41,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static int X;
    static int Y;
    static int [] dx = {-2,-2,-1,-1,1,1,2,2};
    static int [] dy = {1,-1,2,-2,2,-2,1,-1};
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        X = sc.nextInt();
        Y = sc.nextInt();
        if(move(0,0,0)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
    static boolean move(int x, int y, int c){
        if(c>3){
            return false;
        }
        if(x==X&&y==Y){
            return true;
        }
        for(int i=0; i<8; i++){
            if(move(x+dx[i], y+dy[i], c+1)){
                return true;
            }
        }
        return false;
    }
}
0