結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,188 KB
testcase_01 AC 130 ms
41,404 KB
testcase_02 AC 128 ms
41,520 KB
testcase_03 AC 128 ms
41,592 KB
testcase_04 AC 131 ms
41,304 KB
testcase_05 AC 131 ms
41,428 KB
testcase_06 AC 131 ms
41,484 KB
testcase_07 AC 132 ms
41,332 KB
testcase_08 AC 127 ms
41,788 KB
testcase_09 AC 132 ms
41,392 KB
testcase_10 AC 127 ms
41,308 KB
testcase_11 AC 128 ms
41,436 KB
testcase_12 AC 123 ms
41,432 KB
testcase_13 AC 132 ms
41,312 KB
testcase_14 AC 131 ms
41,252 KB
testcase_15 AC 131 ms
41,124 KB
testcase_16 AC 118 ms
40,096 KB
testcase_17 AC 126 ms
41,784 KB
testcase_18 AC 125 ms
41,508 KB
testcase_19 AC 121 ms
41,464 KB
testcase_20 AC 126 ms
41,436 KB
testcase_21 AC 130 ms
41,468 KB
testcase_22 AC 134 ms
41,336 KB
testcase_23 AC 131 ms
41,300 KB
testcase_24 AC 127 ms
41,520 KB
testcase_25 AC 113 ms
41,292 KB
testcase_26 AC 123 ms
41,292 KB
testcase_27 AC 128 ms
41,268 KB
testcase_28 AC 114 ms
41,436 KB
testcase_29 AC 128 ms
41,384 KB
testcase_30 AC 128 ms
41,180 KB
testcase_31 AC 127 ms
41,560 KB
testcase_32 AC 127 ms
41,608 KB
testcase_33 AC 124 ms
41,616 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();
        String ans = move(0,0,0,"NO");
        System.out.println(ans);
    }
    static String move(int x, int y, int c, String S){
        if(c>3){
            return S;
        }
        if(x==X&&y==Y){
            return "YES";
        }
        for(int i=0; i<8; i++){
            S=move(x+dx[i], y+dy[i], c+1, S);
        }
        return S;
    }
}
0