Skip to content

Commit 8c48e96

Browse files
committed
[Silver IV] Title: 점화식, Time: 36 ms, Memory: 32412 KB -BaekjoonHub
1 parent a3088d4 commit 8c48e96

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# [Silver IV] 점화식 - 13699
2+
3+
[문제 링크](https://www.acmicpc.net/problem/13699)
4+
5+
### 성능 요약
6+
7+
메모리: 32412 KB, 시간: 36 ms
8+
9+
### 분류
10+
11+
다이나믹 프로그래밍
12+
13+
### 제출 일자
14+
15+
2025년 5월 5일 20:27:36
16+
17+
### 문제 설명
18+
19+
<p>다음의 점화식에 의해 정의된 수열 t(n)을 생각하자:</p>
20+
21+
<ul>
22+
<li>t(0)=1</li>
23+
<li>t(n)=t(0)*t(n-1)+t(1)*t(n-2)+...+t(n-1)*t(0)</li>
24+
</ul>
25+
26+
<p>이 정의에 따르면,</p>
27+
28+
<ul>
29+
<li>t(1)=t(0)*t(0)=1</li>
30+
<li>t(2)=t(0)*t(1)+t(1)*t(0)=2</li>
31+
<li>t(3)=t(0)*t(2)+t(1)*t(1)+t(2)*t(0)=5</li>
32+
<li>...</li>
33+
</ul>
34+
35+
<p>주어진 입력 0 ≤ n <strong>≤ </strong>35에 대하여 t(n)을 출력하는 프로그램을 작성하시오.</p>
36+
37+
### 입력
38+
39+
<p>첫째 줄에 n (0 ≤ n ≤ 35)이 주어진다.</p>
40+
41+
### 출력
42+
43+
<p>첫째 줄에 t(n)을 출력한다.</p>
44+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 13699 점화식
2+
3+
import sys
4+
input = sys.stdin.readline
5+
6+
n = int(input())
7+
8+
dp = [0] * (n+1)
9+
dp[0] = 1
10+
11+
for k in range(1, n+1):
12+
for i in range(n):
13+
dp[k] += (dp[i]*dp[k-1-i])
14+
15+
print(dp[n])

0 commit comments

Comments
 (0)