結果
問題 | No.894 二種類のバス |
ユーザー | 37zigen |
提出日時 | 2018-02-21 07:47:09 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 135 ms / 1,000 ms |
コード長 | 870 bytes |
コンパイル時間 | 2,184 ms |
コンパイル使用メモリ | 74,208 KB |
実行使用メモリ | 56,488 KB |
最終ジャッジ日時 | 2023-10-12 09:43:25 |
合計ジャッジ時間 | 5,785 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
55,568 KB |
testcase_01 | AC | 124 ms
55,920 KB |
testcase_02 | AC | 124 ms
55,996 KB |
testcase_03 | AC | 122 ms
55,880 KB |
testcase_04 | AC | 125 ms
55,568 KB |
testcase_05 | AC | 124 ms
56,116 KB |
testcase_06 | AC | 135 ms
56,036 KB |
testcase_07 | AC | 125 ms
55,844 KB |
testcase_08 | AC | 123 ms
55,760 KB |
testcase_09 | AC | 123 ms
56,488 KB |
testcase_10 | AC | 126 ms
55,884 KB |
testcase_11 | AC | 126 ms
56,184 KB |
testcase_12 | AC | 123 ms
56,036 KB |
testcase_13 | AC | 126 ms
55,748 KB |
testcase_14 | AC | 125 ms
55,692 KB |
testcase_15 | AC | 126 ms
55,920 KB |
testcase_16 | AC | 126 ms
55,620 KB |
testcase_17 | AC | 127 ms
55,920 KB |
testcase_18 | AC | 125 ms
55,840 KB |
testcase_19 | AC | 123 ms
55,620 KB |
ソースコード
import java.math.BigInteger; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } public void run() { Scanner sc = new Scanner(System.in); long t = sc.nextLong(); long a = sc.nextLong(); long b = sc.nextLong(); if (!(1 <= t && 1 <= a && 1 <= b && t <= 1e18 && a <= 1e18 && b <= 1e18)) throw new AssertionError(); BigInteger T = BigInteger.valueOf(t).subtract(BigInteger.ONE); BigInteger A = BigInteger.valueOf(a); BigInteger B = BigInteger.valueOf(b); BigInteger ans = BigInteger.ZERO; ans = ans.add(T.divide(A)); ans = ans.add(T.divide(B)); ans = ans.subtract(T.divide(A.multiply(B).divide(A.gcd(B)))); ans = ans.add(BigInteger.ONE); System.out.println(ans); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }