結果

問題 No.1973 Divisor Sequence
ユーザー ntudantuda
提出日時 2022-07-03 16:01:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 371 ms / 2,000 ms
コード長 750 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 86,500 KB
実行使用メモリ 77,824 KB
最終ジャッジ日時 2023-08-19 16:02:28
合計ジャッジ時間 5,543 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,480 KB
testcase_01 AC 80 ms
71,380 KB
testcase_02 AC 111 ms
77,436 KB
testcase_03 AC 92 ms
77,328 KB
testcase_04 AC 98 ms
77,192 KB
testcase_05 AC 100 ms
77,196 KB
testcase_06 AC 98 ms
77,304 KB
testcase_07 AC 92 ms
77,224 KB
testcase_08 AC 95 ms
77,400 KB
testcase_09 AC 94 ms
77,264 KB
testcase_10 AC 114 ms
77,144 KB
testcase_11 AC 87 ms
77,292 KB
testcase_12 AC 95 ms
77,440 KB
testcase_13 AC 97 ms
77,524 KB
testcase_14 AC 117 ms
77,516 KB
testcase_15 AC 98 ms
77,392 KB
testcase_16 AC 99 ms
77,360 KB
testcase_17 AC 111 ms
77,324 KB
testcase_18 AC 98 ms
77,644 KB
testcase_19 AC 122 ms
77,824 KB
testcase_20 AC 87 ms
76,992 KB
testcase_21 AC 104 ms
77,452 KB
testcase_22 AC 100 ms
77,484 KB
testcase_23 AC 371 ms
77,488 KB
testcase_24 AC 182 ms
77,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
MOD = 10 ** 9 + 7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def n_fact(N):
    c = Counter(prime_factorize(N))
    return c

N, M = map(int, input().split())
X = n_fact(M)
x2 = Counter(X.values())

ans = 1
for k, v in x2.items():
    dp = [1] * (k + 1)
    for i in range(N-1):
        dp2 = [0] * (k+1)
        sump = 0
        for j in range(k+1):
            sump += dp[j]
            dp2[k-j] = sump % MOD
        dp = dp2
    ans *= pow(sum(dp),v,MOD)
    ans %= MOD

print(ans)

0