We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9ed80b5 commit 6bd0dd4Copy full SHA for 6bd0dd4
Hongjoo/백준/피보나치비스무리한수열.py
@@ -0,0 +1,31 @@
1
+"""
2
+#피보나치 비스무리한수열 / 실버 5
3
+https://www.acmicpc.net/problem/14495
4
+- 조건 : 1< n <=116
5
+
6
+# 문제 유형 : DP
7
+1. 입력
8
+2. dp 생성
9
+dp[1<idx <=n] = [1,1,1...f(n)]
10
+-초기화 : dp[1]=dp[2]=dp[3] = 1
11
12
+3. 점화식
13
+f(n) = f(n-1) + f(n-3)
14
+- dp에 저장하기
15
+- dp에 있으면 호출, 없으면 계산 & dp에 업데이트
16
17
+#1. 입력 변수 저장
18
+N = int(input())
19
+#2. dp 생성 & 초기화
20
+dp = [ 0 for _ in range(116+1)]
21
22
23
+#3. 점화식
24
+for i in range(0,N+1) :
25
+ if i in [0,1,2,3] :
26
+ dp[i] = 1
27
+ elif dp[i] == 0 : # i>=4, dp에 없으면 -> 업데이트
28
29
+ dp[i] = dp[i-1] + dp[i-3]
30
31
+print(dp[N])
0 commit comments