結果

問題 No.208 王将
ユーザー ぴろずぴろず
提出日時 2015-05-15 22:31:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 1,000 ms
コード長 680 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 74,456 KB
実行使用メモリ 56,228 KB
最終ジャッジ日時 2024-04-17 22:34:30
合計ジャッジ時間 6,170 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
53,984 KB
testcase_01 AC 127 ms
54,140 KB
testcase_02 AC 129 ms
54,112 KB
testcase_03 AC 127 ms
54,276 KB
testcase_04 AC 129 ms
53,940 KB
testcase_05 AC 129 ms
54,104 KB
testcase_06 AC 129 ms
54,352 KB
testcase_07 AC 126 ms
54,040 KB
testcase_08 AC 130 ms
54,236 KB
testcase_09 AC 129 ms
53,864 KB
testcase_10 AC 128 ms
53,928 KB
testcase_11 AC 133 ms
56,228 KB
testcase_12 AC 129 ms
54,264 KB
testcase_13 AC 130 ms
54,228 KB
testcase_14 AC 127 ms
54,052 KB
testcase_15 AC 128 ms
54,008 KB
testcase_16 AC 129 ms
54,524 KB
testcase_17 AC 128 ms
54,444 KB
testcase_18 AC 127 ms
54,308 KB
testcase_19 AC 126 ms
54,200 KB
testcase_20 AC 126 ms
54,092 KB
testcase_21 AC 125 ms
54,092 KB
testcase_22 AC 126 ms
53,976 KB
testcase_23 AC 125 ms
54,344 KB
testcase_24 AC 122 ms
54,204 KB
権限があれば一括ダウンロードができます

ソースコード

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