因为编辑问题,所以用图片代表题目,图片第一张是问题描述,第二张图片是例子
3条回答 默认 最新
- chuifengde 2021-12-08 13:52关注
s = input(">>>") l = list(map(int, s.split())) l = sorted(l) cost = [] while len(l) > 1: cost.append((l[0], l[1])) l = l[2:] + [l[0] + l[1]] l = sorted(l) print(cost, l) print(sum([i + j for i, j in cost]))
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报 编辑记录无用 1