結果
| 問題 |
No.1581 Multiple Sequence
|
| コンテスト | |
| ユーザー |
👑 SPD_9X2
|
| 提出日時 | 2021-07-02 23:59:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,599 bytes |
| コンパイル時間 | 177 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 145,440 KB |
| 最終ジャッジ日時 | 2024-06-29 13:32:21 |
| 合計ジャッジ時間 | 3,654 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| other | -- * 21 |
ソースコード
"""
和と最後の数だけで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)
SPD_9X2