Skip to content

Commit 5adb823

Browse files
committed
[BOJ] #2293.동전1 / 골드4 / 45(O)
1 parent 8b6ea14 commit 5adb823

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
n, k = map(int, input().split())
5+
coins = [int(input()) for _ in range(n)]
6+
7+
dp = [0] * (k + 1)
8+
dp[0] = 1 # 0원을 만드는 경우의 수는 1 (아무 동전도 사용하지 않는 경우)
9+
10+
for coin in coins:
11+
for j in range(coin, k+1):
12+
dp[j] += dp[j - coin] # 점화식
13+
14+
print(dp[k])

0 commit comments

Comments
 (0)