2748-b1 성공

This commit is contained in:
sm4640
2026-03-26 16:38:55 +09:00
parent 618f6dc8bf
commit 159c3878a6

View File

@@ -0,0 +1,30 @@
# 피보나치 수 2
import sys
input = sys.stdin.readline
def solution():
n = int(input().rstrip())
dp = [0] * 100
dp[0] = 0
dp[1] = 1
for i in range(2, n+1):
dp[i] = dp[i-1] + dp[i-2]
print(dp[n])
return
solution()
"""
걸린 시간: 3분
시간 복잡도: n까지 dp 테이블을 채우면 되므로 O(n)이다.
해설: i번째 칸을 채우기 위해서는 i-1, i-2번째 값을 알아야하기 때문에 dp테이블에 이전 값들을 기록해가면서 현재 값을 채우면 된다.
"""