結果

問題 No.44 DPなすごろく
ユーザー Theta
提出日時 2022-10-21 19:13:11
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 356 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-01 04:36:41
合計ジャッジ時間 1,653 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache


@lru_cache
def calc_patterns(num: int) -> int:
    match num:
        case 0:
            return 1
        case 1:
            return 1
        case _:
            return calc_patterns(num - 1) + calc_patterns(num - 2)


def main():
    N = int(input())
    print(calc_patterns(N))


if __name__ == "__main__":
    main()
0