結果

問題 No.1973 Divisor Sequence
ユーザー AEnAEn
提出日時 2022-11-23 13:21:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 925 ms / 2,000 ms
コード長 1,164 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 81,696 KB
実行使用メモリ 301,896 KB
最終ジャッジ日時 2023-10-24 22:59:13
合計ジャッジ時間 6,874 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,664 KB
testcase_01 AC 37 ms
53,528 KB
testcase_02 AC 170 ms
124,052 KB
testcase_03 AC 64 ms
73,104 KB
testcase_04 AC 130 ms
104,116 KB
testcase_05 AC 127 ms
100,416 KB
testcase_06 AC 154 ms
115,660 KB
testcase_07 AC 82 ms
82,524 KB
testcase_08 AC 117 ms
97,188 KB
testcase_09 AC 121 ms
100,608 KB
testcase_10 AC 233 ms
138,544 KB
testcase_11 AC 64 ms
71,044 KB
testcase_12 AC 140 ms
107,720 KB
testcase_13 AC 118 ms
94,728 KB
testcase_14 AC 206 ms
116,652 KB
testcase_15 AC 141 ms
109,364 KB
testcase_16 AC 158 ms
116,960 KB
testcase_17 AC 210 ms
128,192 KB
testcase_18 AC 93 ms
79,332 KB
testcase_19 AC 253 ms
144,768 KB
testcase_20 AC 71 ms
73,880 KB
testcase_21 AC 179 ms
124,784 KB
testcase_22 AC 142 ms
109,580 KB
testcase_23 AC 925 ms
282,920 KB
testcase_24 AC 775 ms
301,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

N, M = map(int, input().split())
arr = factorization(M)
res = 1
mod = 10**9+7
calc = {}
for num, cnt in arr:
    if num==1:continue
    if cnt in calc:
        res *= calc[cnt]
        res %= mod
    else:
        dp = [[0]*(cnt+2) for _ in range(N)]
        dp[0][0] = 1
        dp[0][-1] = -1
        for i in range(1,N):
            for j in range(cnt+1):
                dp[i-1][j+1] += dp[i-1][j]
                dp[i-1][j+1] %= mod
            for j in range(cnt+1):
                dp[i][0] += dp[i-1][j]
                dp[i][0] %= mod
                dp[i][cnt-j+1] -= dp[i-1][j]
                dp[i][cnt-j+1] %= mod
        for i in range(cnt+1):
            dp[-1][i+1] += dp[-1][i]
            dp[-1][i+1] %= mod
        calc[cnt] = sum(dp[-1])
        res *= calc[cnt]
        res %= mod

print(res)
0