結果

問題 No.1973 Divisor Sequence
ユーザー rlangevinrlangevin
提出日時 2022-08-25 23:13:18
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,008 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 76,928 KB
最終ジャッジ日時 2024-04-21 05:33:19
合計ジャッジ時間 6,850 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
68,428 KB
testcase_01 AC 50 ms
60,160 KB
testcase_02 AC 363 ms
76,636 KB
testcase_03 AC 72 ms
72,832 KB
testcase_04 AC 245 ms
76,544 KB
testcase_05 AC 97 ms
76,544 KB
testcase_06 AC 169 ms
76,416 KB
testcase_07 AC 91 ms
76,544 KB
testcase_08 AC 131 ms
76,928 KB
testcase_09 AC 219 ms
76,672 KB
testcase_10 AC 748 ms
76,544 KB
testcase_11 AC 98 ms
76,484 KB
testcase_12 AC 157 ms
76,416 KB
testcase_13 AC 118 ms
76,416 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
                
    pre, dp = dp, pre

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