結果
問題 |
No.1581 Multiple Sequence
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:43:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 259 ms / 2,000 ms |
コード長 | 627 bytes |
コンパイル時間 | 186 ms |
コンパイル使用メモリ | 82,112 KB |
実行使用メモリ | 90,440 KB |
最終ジャッジ日時 | 2025-03-31 17:44:57 |
合計ジャッジ時間 | 4,512 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
MOD = 10**9 + 7 M = int(input()) max_m = M factors = [[] for _ in range(max_m + 1)] # Precompute factors for each number up to max_m for i in range(1, max_m + 1): for j in range(i, max_m + 1, i): factors[j].append(i) # Initialize dp array dp = [0] * (max_m + 1) dp[0] = 1 # Base case: sum 0 can be achieved by an empty sequence # Compute dp for each sum from 1 to M for m in range(1, max_m + 1): total = 0 for a in factors[m]: k = (m // a) - 1 if k < 0: continue total += dp[k] if total >= MOD: total -= MOD dp[m] = total % MOD print(dp[M])