結果
| 問題 |
No.894 二種類のバス
|
| コンテスト | |
| ユーザー |
lunnear
|
| 提出日時 | 2019-10-21 19:20:57 |
| 言語 | Java (openjdk 23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 992 bytes |
| コンパイル時間 | 2,136 ms |
| コンパイル使用メモリ | 77,804 KB |
| 実行使用メモリ | 54,856 KB |
| 最終ジャッジ日時 | 2024-07-02 17:51:09 |
| 合計ジャッジ時間 | 5,141 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 RE * 1 |
| other | AC * 1 WA * 4 RE * 12 |
ソースコード
import java.util.Scanner;
import java.math.BigDecimal;
public class Main
{
public static void main(String[] args) throws Exception
{
Scanner scanner = new Scanner(System.in);
BigDecimal t = scanner.nextBigDecimal();
BigDecimal x = scanner.nextBigDecimal();
BigDecimal y = scanner.nextBigDecimal();
BigDecimal z = lcm(x, y);
scanner.close();
BigDecimal ans = BigDecimal.ZERO;
ans = ans.add(t.divide(x));
ans = ans.add(t.divide(y));
ans = ans.subtract(t.divide(z));
System.out.println(ans.toPlainString());
}
private static BigDecimal gcd(BigDecimal x, BigDecimal y)
{
if (x.compareTo(y) < 0)
return _gcd(y, x);
return _gcd(x, y);
}
private static BigDecimal _gcd(BigDecimal x, BigDecimal y)
{
BigDecimal r = x.remainder(y);
if(r.compareTo(BigDecimal.ZERO) == 0)
return y;
return _gcd(y, r);
}
private static BigDecimal lcm(BigDecimal x, BigDecimal y)
{
return x.multiply(y).divide(gcd(x, y));
}
}
lunnear