結果

問題 No.44 DPなすごろく
ユーザー ThetaTheta
提出日時 2022-10-21 19:13:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 356 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 10,496 KB
実行使用メモリ 8,664 KB
最終ジャッジ日時 2023-09-13 20:06:31
合計ジャッジ時間 3,257 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,664 KB
testcase_01 AC 20 ms
8,632 KB
testcase_02 AC 20 ms
8,604 KB
testcase_03 AC 20 ms
8,480 KB
testcase_04 AC 21 ms
8,480 KB
testcase_05 AC 20 ms
8,524 KB
testcase_06 AC 20 ms
8,528 KB
testcase_07 AC 19 ms
8,520 KB
testcase_08 AC 21 ms
8,608 KB
testcase_09 AC 20 ms
8,596 KB
testcase_10 AC 20 ms
8,596 KB
testcase_11 AC 20 ms
8,660 KB
testcase_12 AC 20 ms
8,616 KB
testcase_13 AC 20 ms
8,660 KB
testcase_14 AC 20 ms
8,632 KB
testcase_15 AC 20 ms
8,532 KB
testcase_16 AC 21 ms
8,520 KB
testcase_17 AC 20 ms
8,524 KB
testcase_18 AC 20 ms
8,520 KB
testcase_19 AC 20 ms
8,636 KB
testcase_20 AC 20 ms
8,632 KB
testcase_21 AC 20 ms
8,632 KB
testcase_22 AC 20 ms
8,664 KB
testcase_23 AC 19 ms
8,644 KB
権限があれば一括ダウンロードができます

ソースコード

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