結果

問題 No.894 二種類のバス
ユーザー ks2mks2m
提出日時 2019-09-27 21:45:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 54 ms / 1,000 ms
コード長 711 bytes
コンパイル時間 1,995 ms
コンパイル使用メモリ 74,600 KB
実行使用メモリ 53,508 KB
最終ジャッジ日時 2023-10-25 03:13:15
合計ジャッジ時間 3,729 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
53,488 KB
testcase_01 AC 53 ms
53,488 KB
testcase_02 AC 53 ms
51,604 KB
testcase_03 AC 53 ms
53,508 KB
testcase_04 AC 54 ms
53,484 KB
testcase_05 AC 53 ms
53,504 KB
testcase_06 AC 53 ms
53,492 KB
testcase_07 AC 53 ms
53,492 KB
testcase_08 AC 54 ms
53,484 KB
testcase_09 AC 54 ms
53,504 KB
testcase_10 AC 53 ms
53,480 KB
testcase_11 AC 53 ms
53,492 KB
testcase_12 AC 53 ms
53,496 KB
testcase_13 AC 53 ms
53,484 KB
testcase_14 AC 53 ms
53,480 KB
testcase_15 AC 53 ms
53,492 KB
testcase_16 AC 53 ms
53,484 KB
testcase_17 AC 53 ms
53,504 KB
testcase_18 AC 52 ms
53,496 KB
testcase_19 AC 53 ms
53,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		BigInteger t = new BigInteger(sa[0]).subtract(BigInteger.ONE);
		BigInteger a = new BigInteger(sa[1]);
		BigInteger b = new BigInteger(sa[2]);
		br.close();

		BigInteger x = t.divide(a).add(BigInteger.ONE);
		BigInteger y = t.divide(b).add(BigInteger.ONE);
		BigInteger z = a.multiply(b).divide(a.gcd(b));
		BigInteger w = t.divide(z).add(BigInteger.ONE);
		System.out.println(x.add(y).subtract(w).toString());
	}
}
0