結果

問題 No.894 二種類のバス
コンテスト
ユーザー ganmodokix
提出日時 2019-09-27 22:44:24
言語 JavaScript
(node v26.7.0 + ACL)
コンパイル:
true
実行:
node _filename_ ONLINE_JUDGE
結果
AC  
実行時間 37 ms / 1,000 ms
+ 978µs
コード長 474 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4 ms
コンパイル使用メモリ 6,528 KB
実行使用メモリ 49,408 KB
最終ジャッジ日時 2026-09-15 06:52:31
合計ジャッジ時間 2,136 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

const stdin = require("fs").readFileSync("/dev/stdin", "UTF8");
const [t, a, b] = stdin.split(/\s/).filter(x=>x).map(x=>BigInt(x));

function gcd(a, b) {
    function gcd_core(a, b) {
        return b ? gcd_core(b, a % b) : a;
    }
    return a > b ? gcd_core(a, b) : gcd_core(b, a);
}

const g = gcd(a, b);
const l = a * b / g;
const bus1 = (t + a - 1n) / a;
const bus2 = (t + b - 1n) / b;
const busomni = (t + l - 1n) / l;
console.log((bus1 + bus2 - busomni).toString());
0