下面Python代码用于将输入金额换成最少币种组合方案,其实现算法是( )。
1 def findCoins(coins, Money): 2 coins_used = [] 3 for coin in coins: 4 while Money >= coin: 5 coins_used.append(coin) 6 Money -= coin 7 return coins_used 8 9 coins = [100, 50, 20, 10, 5, 2, 1] #货币种类,单位相同 10 M = int(input()) #输入换算的金额 11 coins_needed = find_coins(coins, M) 12 13 result = [(c,coins_needed.count(c)) for c in coins] 14 result = [x for x in result if x[1] > 0]