結果

問題 No.314 ケンケンパ
ユーザー phtmscgphtmscg
提出日時 2019-04-20 11:56:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 412 ms / 1,000 ms
コード長 322 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 11,872 KB
実行使用メモリ 49,044 KB
最終ジャッジ日時 2023-10-26 01:49:48
合計ジャッジ時間 2,960 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 411 ms
48,516 KB
testcase_01 AC 26 ms
10,068 KB
testcase_02 AC 25 ms
10,068 KB
testcase_03 AC 25 ms
10,068 KB
testcase_04 AC 26 ms
10,068 KB
testcase_05 AC 26 ms
10,068 KB
testcase_06 AC 25 ms
10,068 KB
testcase_07 AC 25 ms
10,068 KB
testcase_08 AC 25 ms
10,068 KB
testcase_09 AC 24 ms
10,068 KB
testcase_10 AC 25 ms
10,076 KB
testcase_11 AC 26 ms
10,080 KB
testcase_12 AC 25 ms
10,084 KB
testcase_13 AC 25 ms
10,096 KB
testcase_14 AC 28 ms
10,288 KB
testcase_15 AC 29 ms
10,460 KB
testcase_16 AC 35 ms
10,968 KB
testcase_17 AC 65 ms
13,872 KB
testcase_18 AC 214 ms
28,588 KB
testcase_19 AC 412 ms
49,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

if N == 1:
    print(1)
elif N == 2:
    print(2)
else:
    dp = [0]*N
    for i in range(1,N):
        if i == 1:
            dp[i] = 1
        elif i == 2:
            dp[i] = 1
        else:
            dp[i] = (dp[i-2]+dp[i-3])%(10**9+7)
    count = dp[N-1]+dp[N-2]+dp[N-3]
    print(count%(10**9+7))
0