結果

問題 No.208 王将
ユーザー ぴろず
提出日時 2015-05-15 22:31:35
言語 Java
(openjdk 23)
結果
AC  
実行時間 128 ms / 1,000 ms
コード長 680 bytes
コンパイル時間 2,010 ms
コンパイル使用メモリ 74,716 KB
実行使用メモリ 41,512 KB
最終ジャッジ日時 2024-10-09 16:16:47
合計ジャッジ時間 5,998 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

package no208;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		if (!jama(x,y,x2,y2)) {
			System.out.println(Math.max(Math.abs(x), Math.abs(y)));
		}else{
			System.out.println(Math.max(Math.abs(x), Math.abs(y)) + 1);
		}
	}

	public static boolean jama(int x,int y,int x2,int y2) {
		if (Math.abs(x) != Math.abs(y)) {
			return false;
		}
		if (Math.abs(x2) != Math.abs(y2)) {
			return false;
		}
		if (x * x2 < 0 || y * y2 < 0) {
			return false;
		}
		return Math.abs(x2) < Math.abs(x);
	}

}
0