結果

問題 No.1158 GCD Products easy
ユーザー kokatsu
提出日時 2022-01-05 21:50:48
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 2,534 ms
コンパイル使用メモリ 205,276 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 13:59:22
合計ジャッジ時間 3,625 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`

ソースコード

diff #

import std;

void main() {
    long A, B, N;
    readf("%d %d %d\n", A, B, N);

    long M = 10 ^^ 9 + 7;

    long res = 1;
    void f(long g, long cnt) {
        if (cnt >= N) {
            res = res * g % M;
            return;
        }
        foreach (i; A .. B+1) {
            f(gcd(g, i), cnt+1);
        }
    }

    foreach (i; A .. B+1) {
        f(i, 1);
    }

    res.writeln;
}
0