結果

問題 No.208 王将
ユーザー koheiarai94koheiarai94
提出日時 2017-09-25 01:34:52
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,064 bytes
コンパイル時間 1,984 ms
コンパイル使用メモリ 77,676 KB
実行使用メモリ 41,508 KB
最終ジャッジ日時 2024-04-26 17:54:09
合計ジャッジ時間 5,999 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
40,320 KB
testcase_01 AC 122 ms
41,080 KB
testcase_02 AC 119 ms
41,176 KB
testcase_03 AC 117 ms
40,068 KB
testcase_04 AC 123 ms
41,272 KB
testcase_05 AC 119 ms
41,292 KB
testcase_06 AC 108 ms
40,108 KB
testcase_07 AC 122 ms
41,212 KB
testcase_08 AC 117 ms
41,052 KB
testcase_09 AC 128 ms
41,396 KB
testcase_10 AC 117 ms
40,224 KB
testcase_11 AC 122 ms
41,376 KB
testcase_12 AC 119 ms
41,424 KB
testcase_13 AC 111 ms
40,220 KB
testcase_14 AC 109 ms
40,300 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 118 ms
41,140 KB
testcase_19 AC 121 ms
41,508 KB
testcase_20 AC 116 ms
41,180 KB
testcase_21 AC 115 ms
40,784 KB
testcase_22 AC 120 ms
41,144 KB
testcase_23 AC 124 ms
41,332 KB
testcase_24 AC 119 ms
41,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

// Yuki 208
// https://yukicoder.me/problems/no/208

public class Main {
	
	public static void main (String[] args) throws InterruptedException {
		Scanner in = new Scanner(System.in);
		
		long x = in.nextLong();
		long y = in.nextLong();
		long x1 = in.nextLong();
		long y1 = in.nextLong();
		
		long answer = Math.max(Math.abs(x), Math.abs(y));
		if (isBetweenOriginandXY(x, y, x1, y1) && isSameSlope(x, y, x1, y1)) {
			answer++;
		}
		System.out.println(answer);
	}
	
	public static boolean isBetweenOriginandXY(long x, long y, long x1, long y1) {
		if (x < 0 && 0 < y && x1 < 0 && 0 < y1) {
			return x < x1 && y1 < y;
		} else if (x < 0 && y < 0 && x1 < 0 && y1 < 0) {
			return x < x1 && y < y1;
		} else if (0 < x && 0 < y && 0 < x1 && 0 < y1) {
			return x1 < x && y1 < y;
		} else if (0 < x && y < 0 && 0 < x1 && y1 < 0) {
			return x1 < x && y < y1;
		} else {
			return false;
		}
	}
	
	public static boolean isSameSlope(long x, long y, long x1, long y1) {
		return Math.abs(x) * Math.abs(y1) == Math.abs(y) * Math.abs(x1);
	}
}
0