結果

問題 No.240 ナイト散歩
ユーザー fjafjafja
提出日時 2017-09-19 20:05:00
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,170 bytes
コンパイル時間 4,225 ms
コンパイル使用メモリ 79,632 KB
実行使用メモリ 41,740 KB
最終ジャッジ日時 2024-11-08 05:44:14
合計ジャッジ時間 9,858 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 23 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class N240
{
	static int x,y,nowx=0,nowy=0,end=0;
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		x=sc.nextInt();y=sc.nextInt();
		check();
		for(int i=0;end==0&&i<=7;i++)
		{	nowx=0;nowy=0;
			move(i);
			check();
			//System.out.print("["+nowx+","+nowy+"]"+" ");
			for(int j=0;end==0&&j<=7;j++)
			{
				move(j);
				check();
				//System.out.print("["+nowx+","+nowy+"]"+" ");
				for(int k=0;end==0&&k<=7;k++)
				{
					move(k);
					check();
					//System.out.println("["+i+","+j+","+k+"]");
					//System.out.println();
				}
			}
		}
		if(end==1){System.out.println("YES");}
		else{System.out.println("NO");}
	}

	static void check()
	{
		if(x==nowx&&y==nowy){end=1;return;}
		else {return ;}
	}


	static void move(int i)
	{
		switch(i)
		{
		case 0:
			nowx+=2;nowy+=1;
			break;
		case 1:
			nowx+=2;nowy-=1;
			break;
		case 2:
			nowx-=2;nowy+=1;
			break;
		case 3:
			nowx-=2;nowy-=1;
			break;
		case 4:
			nowx+=1;nowy+=2;
			break;
		case 5:
			nowx+=1;nowy-=2;
			break;
		case 6:
			nowx-=1;nowy+=2;
			break;
		case 7:
			nowx-=1;nowy-=2;
			break;
		}
	}

}
0