We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 89c726b commit 839fc00Copy full SHA for 839fc00
minjeong/DynamicProgramming/2025-04-17-[백준]-#9084-동전.py
@@ -0,0 +1,17 @@
1
+import sys
2
+input = sys.stdin.readline
3
+
4
+T = int(input())
5
+for _ in range(T):
6
+ N = int(input()) # 동전의 가지 수
7
+ coins = list(map(int, input().split())) # N가지 동전의 각 금액
8
+ M = int(input()) # 목표 금액
9
10
+ dp = [0] * (M+1)
11
+ dp[0] = 1
12
13
+ for coin in coins:
14
+ for i in range(coin, M + 1):
15
+ dp[i] += dp[i - coin]
16
17
+ print(dp[M])
0 commit comments