結果

問題 No.1581 Multiple Sequence
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-07-03 00:32:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 486 ms / 2,000 ms
コード長 2,310 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 77,596 KB
最終ジャッジ日時 2023-09-12 00:52:47
合計ジャッジ時間 7,932 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,332 KB
testcase_01 AC 67 ms
71,312 KB
testcase_02 AC 392 ms
77,404 KB
testcase_03 AC 426 ms
77,452 KB
testcase_04 AC 154 ms
76,928 KB
testcase_05 AC 444 ms
77,424 KB
testcase_06 AC 220 ms
77,128 KB
testcase_07 AC 149 ms
76,804 KB
testcase_08 AC 180 ms
77,076 KB
testcase_09 AC 401 ms
77,324 KB
testcase_10 AC 278 ms
77,132 KB
testcase_11 AC 110 ms
76,692 KB
testcase_12 AC 193 ms
77,044 KB
testcase_13 AC 79 ms
76,364 KB
testcase_14 AC 426 ms
77,140 KB
testcase_15 AC 318 ms
77,344 KB
testcase_16 AC 119 ms
76,716 KB
testcase_17 AC 473 ms
77,460 KB
testcase_18 AC 103 ms
76,688 KB
testcase_19 AC 377 ms
77,184 KB
testcase_20 AC 391 ms
77,596 KB
testcase_21 AC 425 ms
77,396 KB
testcase_22 AC 257 ms
77,296 KB
testcase_23 AC 486 ms
77,564 KB
権限があれば一括ダウンロードができます

ソースコード

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)
"""

"""

初項で場合分けたとしよう。
初項はMの約数である。
初項が1の時は、 M-1 を後ろで分けることになる。
なので、その分け方は M/a[0] の場合と等しい。

"""


from sys import stdin

M = int(stdin.readline())
mod = 10**9+7

ans = [0] * (M+1)
ans[1] = 1

for m in range(2,M+1):

    nans = 1
    for fi in range(1,m):

        if fi**2 > m:
            break

        if m % fi == 0:

            x = fi
            if (m-x) % x == 0:
                nans += ans[(m-x)//x]

            x = m // fi
            if x != fi and (m-x) % x == 0:
                nans += ans[(m-x)//x]

            
    nans %= mod
    ans[m] = nans

print (ans[-1])
    
0