結果

問題 No.314 ケンケンパ
ユーザー FromBooskaFromBooska
提出日時 2023-10-15 15:15:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 1,000 ms
コード長 403 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 83,864 KB
最終ジャッジ日時 2023-10-15 15:15:40
合計ジャッジ時間 3,685 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
83,700 KB
testcase_01 AC 87 ms
71,440 KB
testcase_02 AC 75 ms
71,096 KB
testcase_03 AC 73 ms
71,256 KB
testcase_04 AC 72 ms
71,436 KB
testcase_05 AC 74 ms
71,416 KB
testcase_06 AC 73 ms
71,364 KB
testcase_07 AC 73 ms
71,520 KB
testcase_08 AC 73 ms
71,100 KB
testcase_09 AC 75 ms
71,544 KB
testcase_10 AC 75 ms
71,364 KB
testcase_11 AC 74 ms
71,296 KB
testcase_12 AC 73 ms
71,476 KB
testcase_13 AC 76 ms
71,248 KB
testcase_14 AC 77 ms
76,212 KB
testcase_15 AC 77 ms
76,192 KB
testcase_16 AC 78 ms
76,472 KB
testcase_17 AC 78 ms
76,992 KB
testcase_18 AC 82 ms
80,028 KB
testcase_19 AC 85 ms
83,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# やり方違った気がするが1次元dp
# dp[i]Pを置く場合数、答えは最後の3項の合計

N = int(input())
mod = 10**9+7
dp = [0]*(N+1)
dp[0] = 1
for i in range(N+1):
    dp[i] %= mod
    if i+2 <= N:
        dp[i+2] += dp[i]
    if i+3 <= N:
        dp[i+3] += dp[i]
if N == 1:
    ans = 1
elif N == 2:
    ans = 2
elif N >= 3:
    ans = dp[N]+dp[N-1]+dp[N-2]
    ans %= mod
print(ans)
0