結果

問題 No.894 二種類のバス
ユーザー takeya_okinotakeya_okino
提出日時 2019-09-28 11:43:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 497 bytes
コンパイル時間 1,841 ms
コンパイル使用メモリ 74,592 KB
実行使用メモリ 54,408 KB
最終ジャッジ日時 2024-04-09 20:08:43
合計ジャッジ時間 4,948 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
54,360 KB
testcase_01 AC 111 ms
53,564 KB
testcase_02 AC 107 ms
53,052 KB
testcase_03 AC 103 ms
52,728 KB
testcase_04 AC 118 ms
54,148 KB
testcase_05 AC 118 ms
53,972 KB
testcase_06 AC 105 ms
53,036 KB
testcase_07 AC 118 ms
54,112 KB
testcase_08 WA -
testcase_09 AC 119 ms
54,060 KB
testcase_10 AC 119 ms
54,276 KB
testcase_11 AC 121 ms
54,168 KB
testcase_12 AC 119 ms
54,044 KB
testcase_13 AC 107 ms
52,976 KB
testcase_14 AC 102 ms
54,408 KB
testcase_15 AC 103 ms
53,076 KB
testcase_16 AC 114 ms
54,048 KB
testcase_17 AC 102 ms
52,856 KB
testcase_18 AC 119 ms
54,052 KB
testcase_19 AC 122 ms
54,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long t = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();

    long ans = 2 + (t - 1) / a;

    long g = gcd(a, b);
    long g1 = g * (a / g) * (b / g);

    ans -= (1 + (t - 1) / g1);

    ans += (t - 1) / b;

    System.out.println(ans);
  }

  public static long gcd(long a, long b) {
    if(b == 0) return a;
    return gcd(b, (a % b));
  }
}
0