結果

問題 No.1973 Divisor Sequence
ユーザー EguyEguy
提出日時 2022-06-11 00:13:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 681 ms / 2,000 ms
コード長 1,161 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 81,756 KB
実行使用メモリ 75,872 KB
最終ジャッジ日時 2023-10-21 06:23:15
合計ジャッジ時間 6,365 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,548 KB
testcase_01 AC 40 ms
53,548 KB
testcase_02 AC 332 ms
75,780 KB
testcase_03 AC 82 ms
75,732 KB
testcase_04 AC 221 ms
75,768 KB
testcase_05 AC 118 ms
75,716 KB
testcase_06 AC 244 ms
75,764 KB
testcase_07 AC 95 ms
75,748 KB
testcase_08 AC 160 ms
75,756 KB
testcase_09 AC 199 ms
75,768 KB
testcase_10 AC 224 ms
75,788 KB
testcase_11 AC 84 ms
75,748 KB
testcase_12 AC 208 ms
75,764 KB
testcase_13 AC 103 ms
75,752 KB
testcase_14 AC 156 ms
75,744 KB
testcase_15 AC 272 ms
75,764 KB
testcase_16 AC 290 ms
75,776 KB
testcase_17 AC 195 ms
75,808 KB
testcase_18 AC 74 ms
75,776 KB
testcase_19 AC 237 ms
75,812 KB
testcase_20 AC 94 ms
75,748 KB
testcase_21 AC 286 ms
75,772 KB
testcase_22 AC 250 ms
75,772 KB
testcase_23 AC 681 ms
75,708 KB
testcase_24 AC 576 ms
75,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, math
sys.setrecursionlimit(1000000)
INF = 1 << 100
mod = 1000000007
#mod = 998244353
input = lambda: sys.stdin.readline().rstrip()
li = lambda: list(map(int, input().split()))

def factorization(x):
    lst = []
    if x == 1:
        return lst
    
    # 何度も回す場合、範囲を素数のみにするといいかも
    for n in range(2, x + 1):
        if n * n > x or x == 1:
            break
        count = 0
        while x % n == 0:
            x //= n
            count += 1
        if count:
            lst.append((n, count))

    if x > 1:
        lst.append((x, 1))

    return lst
N, M = li()
fac = factorization(M)
X = len(fac)
Y = 0
dp = []
for i in range(X):
    k, v = fac[i]
    Y = max(Y, v+1)

dp = [[1] * Y for _ in range(X)]
for _ in range(N-1):
    ndp = [[0] * Y for _ in range(X)]
    for i in range(X):
        _, v = fac[i]
        tmp = 0
        for e, j in enumerate(reversed(range(v+1))):
            tmp += dp[i][e]
            tmp %= mod
            ndp[i][j] += tmp
            ndp[i][j] %= mod
    dp = ndp

ans = 1
for i in range(X):
    tmp = sum(dp[i]) % mod
    ans *= tmp
    ans %= mod

print(ans)
0