[백준] 9084번: 동전

whitehousechef·2023년 9월 18일
0

initial

I tried representing dp[i] as the number of ways to reach amount i.

업로드중..

initial wrong code:

t = int(input())

for _ in range(t):
    n = int(input())
    coins = list(map(int, input().split()))
    amount = int(input())
    
    dp = [0 for _ in range(amount + 1)]
    
    for coin in coins:
        dp[coin] = 1
    
    for i in range(1, amount + 1):
        for coin in coins:
            if i >= coin:
                dp[i] += dp[i - coin]
    
    print(dp[amount])

0개의 댓글