File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+
Original file line number Diff line number Diff line change 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 ])
You can’t perform that action at this time.
0 commit comments