結果
問題 |
No.208 王将
|
ユーザー |
![]() |
提出日時 | 2017-09-25 01:40:23 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,202 bytes |
コンパイル時間 | 2,431 ms |
コンパイル使用メモリ | 77,844 KB |
実行使用メモリ | 54,308 KB |
最終ジャッジ日時 | 2024-11-14 07:35:41 |
合計ジャッジ時間 | 5,974 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 WA * 3 |
ソースコード
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); long answer = Math.max(x, y); if (x1 < x && y1 < y && x * y1 == y * x1) { 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); } }