結果

問題 No.1581 Multiple Sequence
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-07-02 23:59:05
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,599 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 153,708 KB
最終ジャッジ日時 2023-09-12 00:19:37
合計ジャッジ時間 4,217 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,648 KB
testcase_01 AC 95 ms
71,764 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

和と最後の数だけでdpできる。
dp[last][rem] = 通り数

sumは同じだけ増えるし、調和級数なのでそこそこ早い

だめでした

dp[x] = xの崩し方


"""
"""
from sys import stdin
from collections import deque

for M in range(1,50):
    mod = 10**9+7

    q = deque()
    ans = {}
    ans[(1,M)] = 1
    q.append( (1,M) )

    while q:

        last,rem = q.popleft()

        for nex in range(last,rem+1,last):

            tup = (nex,rem-nex)
            if tup not in ans:
                ans[tup] = 0
                q.append(tup)
            ans[tup] += ans[(last,rem)]
            ans[tup] %= mod

    #print (len(ans))
    pans = 0 
    for tup in ans:
        if tup[1] == 0:
            pans += ans[tup]

    print (M,pans % mod)

"""
"""

初項を持ってdp?
確かに初項を考えると、それ以降その倍数しか取れない
初項は、Mの約数であることがわかる
上のdpで初項をMの約数で限れば?

待てよ…
remはnexの倍数である必要がある

"""

from sys import stdin
from collections import deque


mod = 10**9+7
M = int(input())

q = deque()
ans = {}
ans[(1,M)] = 1
q.append( (1,M) )

while q:

    last,rem = q.popleft()

    for nex in range(last,rem+1,last):

        if (rem - nex) % nex == 0:
            tup = (nex,rem-nex)
            if tup not in ans:
                ans[tup] = 0
                q.append(tup)
            ans[tup] += ans[(last,rem)]
            ans[tup] %= mod

#print (len(ans))
pans = 0 
for tup in ans:
    if tup[1] == 0:
        pans += ans[tup]

print (pans % mod)
0