Algorithm/Problems
99클럽 코테 스터디 29일차 TIL + DP
공부좀하시졍
2024. 11. 25. 21:18
https://www.acmicpc.net/problem/9461
import sys
input = sys.stdin.readline
t = int(input())
dp = [0] * 101
dp[1] = 1
dp[2] = 1
dp[3] = 1
for i in range(4,101):
dp[i] = dp[i-2] + dp[i-3]
for _ in range(t):
print(dp[int(input())])
- n=1일 때부터 쭉 나열해 점화식을 파악할 수 있다.
- 1 1 1 2 2 3 4 5 7 9 16 21 ..
- n은 100이하의 수니까 dp 리스트에 계산한 값을 초기화한다.