結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
spacia
|
| 提出日時 | 2016-01-04 20:56:11 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 71 ms / 2,000 ms |
| コード長 | 799 bytes |
| コンパイル時間 | 1,955 ms |
| コンパイル使用メモリ | 77,768 KB |
| 実行使用メモリ | 51,616 KB |
| 最終ジャッジ日時 | 2024-10-07 21:18:46 |
| 合計ジャッジ時間 | 4,943 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
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");
}
}
spacia