結果
問題 |
No.2521 Don't be Same
|
ユーザー |
![]() |
提出日時 | 2023-10-27 23:49:03 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 237 ms / 2,000 ms |
コード長 | 1,651 bytes |
コンパイル時間 | 2,475 ms |
コンパイル使用メモリ | 79,148 KB |
実行使用メモリ | 58,480 KB |
平均クエリ数 | 9.75 |
最終ジャッジ日時 | 2024-09-25 15:34:53 |
合計ジャッジ時間 | 10,369 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); int a = Math.min(x, y); int b = Math.max(x, y); boolean f = true; if (a + 1 == b && a % 2 == 1) { f = false; } if (f) { System.out.println("First"); if (x == y) { System.out.println("B"); x = 0; y = 0; } else if (x > y) { int r = 0; if (y == 0) { r = x; } else if (y % 2 == 0) { r = x - y + 1; } else { r = x - y - 1; } System.out.println("A 1 " + r); x -= r; } else { int r = 0; if (x == 0) { r = y; } else if (x % 2 == 0) { r = y - x + 1; } else { r = y - x - 1; } System.out.println("A 2 " + r); y -= r; } } else { System.out.println("Second"); } while (true) { String s = sc.next(); if (s.equals("C") || s.equals("D")) { break; } if (s.equals("B")) { x = 0; y = 0; } else { int i = sc.nextInt(); int n = sc.nextInt(); if (i == 1) { x -= n; } else { y -= n; } } if (x == y) { System.out.println("B"); x = 0; y = 0; } else if (x > y) { int r = 0; if (y == 0) { r = x; } else if (y % 2 == 0) { r = x - y + 1; } else { r = x - y - 1; } System.out.println("A 1 " + r); x -= r; } else { int r = 0; if (x == 0) { r = y; } else if (x % 2 == 0) { r = y - x + 1; } else { r = y - x - 1; } System.out.println("A 2 " + r); y -= r; } } sc.close(); } }