結果

問題 No.1877 俺自身が線グラフになることだ
ユーザー 👑 rin204rin204
提出日時 2022-03-18 21:39:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,231 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 82,492 KB
実行使用メモリ 103,664 KB
最終ジャッジ日時 2024-04-14 09:24:12
合計ジャッジ時間 2,584 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,560 KB
testcase_01 AC 37 ms
52,616 KB
testcase_02 AC 38 ms
52,692 KB
testcase_03 AC 38 ms
52,336 KB
testcase_04 AC 38 ms
52,636 KB
testcase_05 AC 38 ms
52,148 KB
testcase_06 AC 38 ms
52,196 KB
testcase_07 AC 37 ms
52,576 KB
testcase_08 AC 38 ms
52,136 KB
testcase_09 AC 38 ms
52,728 KB
testcase_10 AC 57 ms
66,024 KB
testcase_11 AC 1,231 ms
103,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000)
MOD = 10 ** 9 + 7
    
n = int(input())
memo = {}
def dfs(n, max_):
    if n == 0:
        return 1
    elif n < max_:
        return 0
    elif n * 10000 + max_ in memo:
        return memo[n * 10000 + max_]
    ret = 0
    for i in range(max_, n + 1):
        ret += dfs(n - i, i)
        ret %= MOD
    
    memo[n * 10000 + max_] = ret
    return ret
    
print(dfs(n, 3))
0