結果

問題 No.1973 Divisor Sequence
ユーザー rlangevinrlangevin
提出日時 2022-08-25 23:14:01
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,034 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 82,844 KB
実行使用メモリ 83,596 KB
最終ジャッジ日時 2024-04-21 05:33:37
合計ジャッジ時間 7,142 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
66,176 KB
testcase_01 AC 59 ms
60,160 KB
testcase_02 AC 451 ms
76,544 KB
testcase_03 AC 85 ms
73,216 KB
testcase_04 AC 304 ms
76,448 KB
testcase_05 AC 110 ms
76,616 KB
testcase_06 AC 211 ms
76,544 KB
testcase_07 AC 114 ms
76,668 KB
testcase_08 AC 157 ms
76,632 KB
testcase_09 AC 271 ms
76,504 KB
testcase_10 AC 882 ms
76,800 KB
testcase_11 AC 113 ms
76,388 KB
testcase_12 AC 189 ms
76,788 KB
testcase_13 AC 133 ms
76,508 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
def compress(lst):
    B = []
    D = dict()
    from copy import deepcopy
    vals = deepcopy(lst)
    vals = list(set(vals))
    vals.sort()
    from bisect import bisect_left
    for i in range(len(lst)):
        ind = bisect_left(vals, lst[i])
        B.append(ind)
    for i in range(len(B)):
        D[lst[i]] = B[i]
    return B, D

def div(n):
    S = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            S.add(i)
            S.add(n // i)
        i += 1
    return sorted(list(S))

N, M = map(int, input().split())
mod = 10 ** 9 + 7
L = div(M)
K = len(L)
LB, LD = compress(L)

lst = [[] for _ in range(K)]
for k in L:
    for nk in L:
        if (M // k) % nk == 0:
            lst[LD[nk]].append(LD[k])

pre = [0] * K
pre[LD[1]] = 1
for i in range(N):
    dp = [0] * K
    for j in range(K):
        c = pre[j] % mod
        for nk in lst[j]:
            dp[nk] += c
            dp[nk] %= mod
                
    pre, dp = dp, pre

ans = sum(pre)%mod
print(ans % mod)
0