結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー shi-mo
提出日時 2016-10-24 23:47:11
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 385 bytes
コンパイル時間 1,721 ms
コンパイル使用メモリ 139,136 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-12 04:42:22
合計ジャッジ時間 3,048 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`

ソースコード

diff #

import std.stdio;
import std.numeric;

void main() {
    ulong n; readf("%s\n", &n);
    ulong a, b, c; readf("%s %s %s", &a, &b, &c);

    ulong m = n/a + n/b + n/c;
    m -= n/a.lcm(b) + n/b.lcm(c) + n/c.lcm(a);
    m += n/a.lcm(b).lcm(c);
    writeln(m);
}

ulong lcm(ulong a, ulong b) {
    ulong g = gcd(a, b);
    ulong na = a / g;
    ulong nb = b / g;
    return na * nb * g;
}
0