結果

問題 No.1877 俺自身が線グラフになることだ
ユーザー mkawa2mkawa2
提出日時 2022-03-18 22:31:08
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,127 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 82,344 KB
実行使用メモリ 72,004 KB
最終ジャッジ日時 2024-04-14 10:25:46
合計ジャッジ時間 1,616 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 41 ms
53,156 KB
testcase_03 AC 38 ms
52,964 KB
testcase_04 AC 39 ms
53,908 KB
testcase_05 AC 39 ms
53,732 KB
testcase_06 AC 41 ms
52,888 KB
testcase_07 AC 38 ms
52,952 KB
testcase_08 AC 38 ms
53,424 KB
testcase_09 AC 38 ms
54,508 KB
testcase_10 AC 48 ms
62,272 KB
testcase_11 AC 65 ms
72,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

n = II()

dp = [[0]*(n+1) for _ in range(n+1)]

dp[3][1] = 1

for i in range(3,n):
    for j in range(1,n+1):
        pre = dp[i][j]
        if pre == 0: continue
        if i+3<=n:
            dp[i+3][j+1] += pre
            dp[i+3][j+1] %= md
        if i+j <= n:
            dp[i+j][j] += pre
            dp[i+j][j] %= md

ans = 0
for j in range(1,n+1):
    ans += dp[n][j]
    ans %= md

print(ans)
0