結果

問題 No.816 Beautiful tuples
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-19 23:18:53
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 777 bytes
コンパイル時間 2,203 ms
コンパイル使用メモリ 77,512 KB
実行使用メモリ 56,176 KB
最終ジャッジ日時 2024-04-15 13:16:05
合計ジャッジ時間 5,102 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
53,924 KB
testcase_01 WA -
testcase_02 AC 136 ms
54,220 KB
testcase_03 AC 138 ms
53,928 KB
testcase_04 AC 139 ms
54,200 KB
testcase_05 AC 137 ms
54,360 KB
testcase_06 AC 143 ms
54,432 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 138 ms
54,468 KB
testcase_11 AC 140 ms
54,248 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long ans = (long)Math.pow(10, 18) + 1;
    if(a > b) {
      // 2x, x
      if(a == (2 * b)) ans = Math.min(ans, 3 * b);
      // 3x, x
      if(a == (3 * b)) ans = Math.min(ans, 2 * b);
      // 3x, 2x
      if((a % 3 == 0) && (b % 2 == 0) && ((a / 3) == (b / 2))) ans = Math.min(ans, b / 2);
    } else {
      // x, 2x
      if(b == (2 * a)) ans = Math.min(ans, 3 * a);
      // x, 3x
      if(b == (3 * a)) ans = Math.min(ans, 2 * a);
      // 2x, 3x 
      if((b % 3 == 0) && (a % 2 == 0) && ((b / 3) == (a / 2))) ans = Math.min(ans, a / 2);     
    }
    System.out.println(ans);
  }
}
0