結果

問題 No.1973 Divisor Sequence
ユーザー kokatsukokatsu
提出日時 2022-06-11 23:09:13
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 584 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 3,008 ms
コンパイル使用メモリ 200,768 KB
実行使用メモリ 200,300 KB
最終ジャッジ日時 2023-09-04 17:24:34
合計ジャッジ時間 7,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 283 ms
94,424 KB
testcase_03 AC 15 ms
8,944 KB
testcase_04 AC 155 ms
47,124 KB
testcase_05 AC 42 ms
15,672 KB
testcase_06 AC 173 ms
62,908 KB
testcase_07 AC 30 ms
12,892 KB
testcase_08 AC 89 ms
35,528 KB
testcase_09 AC 137 ms
40,456 KB
testcase_10 AC 175 ms
67,164 KB
testcase_11 AC 22 ms
11,548 KB
testcase_12 AC 140 ms
52,036 KB
testcase_13 AC 37 ms
13,056 KB
testcase_14 AC 99 ms
29,912 KB
testcase_15 AC 230 ms
89,664 KB
testcase_16 AC 228 ms
86,900 KB
testcase_17 AC 146 ms
43,600 KB
testcase_18 AC 10 ms
7,440 KB
testcase_19 AC 191 ms
71,836 KB
testcase_20 AC 31 ms
13,916 KB
testcase_21 AC 216 ms
77,812 KB
testcase_22 AC 188 ms
71,796 KB
testcase_23 AC 282 ms
200,300 KB
testcase_24 AC 584 ms
126,636 KB
権限があれば一括ダウンロードができます

ソースコード

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