結果

問題 No.240 ナイト散歩
ユーザー spaciaspacia
提出日時 2016-01-04 20:56:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 76,732 KB
実行使用メモリ 38,568 KB
最終ジャッジ日時 2024-04-16 19:39:00
合計ジャッジ時間 4,936 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
36,692 KB
testcase_01 AC 49 ms
36,568 KB
testcase_02 AC 69 ms
38,248 KB
testcase_03 AC 54 ms
36,724 KB
testcase_04 AC 72 ms
38,256 KB
testcase_05 AC 70 ms
38,376 KB
testcase_06 AC 54 ms
36,656 KB
testcase_07 AC 71 ms
38,248 KB
testcase_08 AC 54 ms
36,860 KB
testcase_09 AC 53 ms
36,628 KB
testcase_10 AC 53 ms
36,880 KB
testcase_11 AC 56 ms
36,488 KB
testcase_12 AC 51 ms
36,884 KB
testcase_13 AC 52 ms
36,796 KB
testcase_14 AC 52 ms
37,148 KB
testcase_15 AC 52 ms
36,628 KB
testcase_16 AC 53 ms
36,940 KB
testcase_17 AC 54 ms
36,880 KB
testcase_18 AC 72 ms
38,200 KB
testcase_19 AC 70 ms
38,556 KB
testcase_20 AC 71 ms
38,284 KB
testcase_21 AC 73 ms
38,152 KB
testcase_22 AC 73 ms
38,540 KB
testcase_23 AC 68 ms
38,428 KB
testcase_24 AC 70 ms
38,056 KB
testcase_25 AC 69 ms
38,288 KB
testcase_26 AC 68 ms
38,056 KB
testcase_27 AC 68 ms
38,568 KB
testcase_28 AC 52 ms
36,800 KB
testcase_29 AC 52 ms
36,824 KB
testcase_30 AC 50 ms
36,872 KB
testcase_31 AC 52 ms
36,732 KB
testcase_32 AC 51 ms
36,712 KB
testcase_33 AC 52 ms
36,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.math.*;

class Main {
	
	static int goalX , goalY;
	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 out (Object o) {
		System.out.println(o);
	}
	
	public static void solve (int x , int y , int n) {
		if (x == goalX && y == goalY) {
			out("YES");
			System.exit(0);
		}
		if (n == 3) return;
		
		for (int i = 0; i < dx.length; i++) {
			solve(x + dx[i] , y + dy[i] , n + 1);
		}
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		String[] line = br.readLine().split(" ");
		goalX = Integer.parseInt(line[0]);
		goalY = Integer.parseInt(line[1]);
		
		solve(0 , 0 , 0);
		
		out("NO");
	}
}
0