結果
| 問題 | No.1581 Multiple Sequence |
| コンテスト | |
| ユーザー |
👑 SPD_9X2
|
| 提出日時 | 2021-07-02 23:59:05 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,599 bytes |
| 記録 | |
| コンパイル時間 | 321 ms |
| コンパイル使用メモリ | 84,864 KB |
| 実行使用メモリ | 257,104 KB |
| 最終ジャッジ日時 | 2026-03-19 01:52:34 |
| 合計ジャッジ時間 | 60,106 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| other | WA * 4 TLE * 17 |
ソースコード
"""
和と最後の数だけで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