第13751题 单选题
以下实现最少币种找零的Python代码采用的是哪种算法?
def findCoins(coins, Money):
  coins_used = []
  for coin in coins:
    while Money >= coin:
      coins_used.append(coin)
      Money -= coin
  return coins_used

coins = [100, 50, 20, 10, 5, 2, 1] #货币种类,单位相同
M = int(input()) #输入换算的金额
coins_needed = find_coins(coins, M)

result = [(c,coins_needed.count(c)) for c in coins]
result = [x for x in result if x[1] > 0]
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析