結果

問題 No.240 ナイト散歩
ユーザー kohaku_kohaku
提出日時 2016-12-12 01:48:13
言語 Java
(openjdk 23)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 666 bytes
コンパイル時間 2,063 ms
コンパイル使用メモリ 74,396 KB
実行使用メモリ 54,356 KB
最終ジャッジ日時 2024-10-07 21:33:28
合計ジャッジ時間 7,496 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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