728x90
반응형
기본적인 다이나믹 프로그래밍 문제이다.
def koong(n):
if n < 2:
return 1
if n == 2:
return 2
if n == 3:
return 4
if dp[n]:
return dp[n]
dp[n] = koong(n-1) + koong(n-2) + koong(n-3) + koong(n-4)
return dp[n]
dp = [0]*68
for _ in range(int(input())):
n = int(input())
print(koong(n))
728x90
반응형
'Agorithm > 백준 알고리즘' 카테고리의 다른 글
백준 알고리즘 15624번 피보나치 수 7(python) (0) | 2021.03.19 |
---|---|
백준 알고리즘 14495번 피보나치 비스무리한 수열(python) (0) | 2021.03.19 |
백준 알고리즘 2193번 이친수(python) (0) | 2021.03.19 |
백준 알고리즘 14606번 피자 (Small)(python) (0) | 2021.03.19 |
백준 알고리즘 13699번 점화식(python) (0) | 2021.03.19 |