結果
| 問題 | No.894 二種類のバス |
| コンテスト | |
| ユーザー |
37zigen
|
| 提出日時 | 2018-02-21 07:47:09 |
| 言語 | Java (openjdk 27.0.1.0.3 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 57 ms / 1,000 ms |
| + 345µs | |
| コード長 | 870 bytes |
| 記録 | |
| コンパイル時間 | 1,486 ms |
| コンパイル使用メモリ | 87,136 KB |
| 実行使用メモリ | 42,752 KB |
| 最終ジャッジ日時 | 2026-10-12 14:52:29 |
| 合計ジャッジ時間 | 3,994 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
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));
}
}
37zigen