Skip to content

Commit e08e5f1

Browse files
authored
[BOJ] 1, 2, 3 더하기 4 (골드5)
1 parent 3f4e9f3 commit e08e5f1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

김지호/9주차/260308.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# https://www.acmicpc.net/problem/15989
2+
# 1, 2, 3 더하기 4, 골드5
3+
4+
import sys
5+
import copy
6+
from collections import deque, defaultdict
7+
from typing import List
8+
9+
N = int(input())
10+
numbers = []
11+
for _ in range(N):
12+
numbers.append(int(input()))
13+
14+
max_number = max(numbers)
15+
dp = [
16+
[0,0,0],
17+
[1,0,0],
18+
[1,1,0],
19+
[1,1,1],
20+
]
21+
for i in range(4,max_number + 1):
22+
# print(f"tesitng index : {i}")
23+
temp = []
24+
temp.append(dp[i-1][0])
25+
temp.append(dp[i-2][0] + dp[i-2][1])
26+
temp.append(dp[i-3][0] + dp[i-3][1] + dp[i-3][2])
27+
28+
dp.append(temp)
29+
30+
for number in numbers:
31+
print(sum(dp[number]))

0 commit comments

Comments
 (0)