結果

問題 No.1973 Divisor Sequence
ユーザー kokatsu
提出日時 2022-06-11 23:09:13
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 594 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 2,293 ms
コンパイル使用メモリ 204,952 KB
実行使用メモリ 199,340 KB
最終ジャッジ日時 2024-06-22 15:26:07
合計ジャッジ時間 6,631 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

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

    enum long MOD = 10 ^^ 9 + 7;

    void addMod(ref long x, long y) {
        x = (x + y) % MOD;
    }

    long[long] cnts;
    long d = 2;
    while (d * d <= M) {
        while (M % d == 0) {
            ++cnts[d];
            M /= d;
        }
        ++d;
    }

    if (M > 1) ++cnts[M];

    long res = 1;
    foreach (key, val; cnts) {
        auto dp = new long[][](N+1, val+1);
        dp[0][0] = 1;
        foreach (i; 1 .. N+1) {
            long tmp;
            foreach_reverse (j; 0 .. val+1) {
                addMod(tmp, dp[i-1][val-j]);
                dp[i][j] = tmp;
            }
        }

        long num = dp[N].fold!((a, b) => (a + b) % MOD);
        res = (res * num) % MOD;
    }

    res.writeln;
}
0