結果

問題 No.44 DPなすごろく
ユーザー sue_charosue_charo
提出日時 2017-04-21 17:20:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 9,964 KB
最終ジャッジ日時 2023-09-27 11:00:54
合計ジャッジ時間 1,963 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
9,872 KB
testcase_01 AC 27 ms
9,912 KB
testcase_02 AC 28 ms
9,868 KB
testcase_03 AC 28 ms
9,896 KB
testcase_04 AC 27 ms
9,904 KB
testcase_05 AC 26 ms
9,812 KB
testcase_06 AC 26 ms
9,812 KB
testcase_07 AC 27 ms
9,964 KB
testcase_08 AC 27 ms
9,900 KB
testcase_09 AC 26 ms
9,888 KB
testcase_10 AC 27 ms
9,864 KB
testcase_11 AC 27 ms
9,812 KB
testcase_12 AC 26 ms
9,964 KB
testcase_13 AC 27 ms
9,960 KB
testcase_14 AC 27 ms
9,896 KB
testcase_15 AC 27 ms
9,964 KB
testcase_16 AC 25 ms
9,864 KB
testcase_17 AC 26 ms
9,880 KB
testcase_18 AC 26 ms
9,896 KB
testcase_19 AC 27 ms
9,816 KB
testcase_20 AC 26 ms
9,876 KB
testcase_21 AC 26 ms
9,920 KB
testcase_22 AC 27 ms
9,812 KB
testcase_23 AC 26 ms
9,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
 
 
def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}
 
 
def solve(N):
    dp = [0] * (N + 1)
    dp[0] = 1
    dp[1] = 1

    def move(now=N):
        if dp[now] != 0:
            return dp[now]

        else:
            dp[now] = move(now - 1) + move(now - 2)
            return dp[now]

    ans = move()

    return ans

def main():
    N = II()
    print(solve(N))
 
 
if __name__ == "__main__":
    main()
0