結果

問題 No.314 ケンケンパ
ユーザー magurogumamaguroguma
提出日時 2017-09-02 18:04:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 343 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 19,072 KB
最終ジャッジ日時 2024-04-24 10:55:17
合計ジャッジ時間 1,962 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 53 ms
18,560 KB
testcase_02 AC 48 ms
18,560 KB
testcase_03 AC 47 ms
18,688 KB
testcase_04 AC 48 ms
18,560 KB
testcase_05 AC 48 ms
18,688 KB
testcase_06 AC 45 ms
18,560 KB
testcase_07 AC 49 ms
18,560 KB
testcase_08 AC 48 ms
18,560 KB
testcase_09 AC 47 ms
18,560 KB
testcase_10 AC 49 ms
18,560 KB
testcase_11 AC 48 ms
18,560 KB
testcase_12 AC 47 ms
18,560 KB
testcase_13 AC 47 ms
18,560 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

N = int(input())
modulo = 10**9 + 7

dp = [-1] * (10**6+1)
def solution(n):
    if dp[n] > -1:
        return dp[n]

    num = -1
    if n==1:
        num = 1
    elif n==2 or n==3:
        num = 2
    else:
        num = solution(n-2) + solution(n-3)
    
    dp[n] = num
    return dp[n]

print(solution(N) % modulo)
0