結果

問題 No.314 ケンケンパ
ユーザー fmhrfmhr
提出日時 2015-12-07 10:39:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 1,000 ms
コード長 413 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 91,612 KB
最終ジャッジ日時 2023-10-12 19:53:57
合計ジャッジ時間 2,911 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
91,432 KB
testcase_01 AC 72 ms
71,048 KB
testcase_02 AC 72 ms
71,240 KB
testcase_03 AC 72 ms
71,204 KB
testcase_04 AC 73 ms
71,244 KB
testcase_05 AC 73 ms
71,056 KB
testcase_06 AC 73 ms
71,060 KB
testcase_07 AC 72 ms
71,204 KB
testcase_08 AC 71 ms
71,204 KB
testcase_09 AC 72 ms
71,236 KB
testcase_10 AC 73 ms
71,476 KB
testcase_11 AC 72 ms
71,060 KB
testcase_12 AC 72 ms
71,468 KB
testcase_13 AC 74 ms
71,180 KB
testcase_14 AC 76 ms
76,080 KB
testcase_15 AC 77 ms
75,804 KB
testcase_16 AC 76 ms
76,296 KB
testcase_17 AC 79 ms
77,720 KB
testcase_18 AC 84 ms
83,572 KB
testcase_19 AC 94 ms
91,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:utf-8

p = 10**9+7
N = int(input())
dp = [0]*(N+10)
dp[0] = 1
dp[1] = 2
dp[2] = 2
pa_point = [0]*(N+10)
pa_point[1] = 1
pa_point[2] = 1
pa_point[3] = 1
pa_point[4] = 2
pa_point[5] = 1
for i in range(3, N):
    # パから2つめで2分岐する
    dp[i] = (dp[i-1]+pa_point[i-2])%p
    pa_point[i+2] = (pa_point[i+2]+pa_point[i])%p
    pa_point[i+3] = (pa_point[i+3]+pa_point[i])%p
print(dp[N-1]%p)
0