damaged = 0 # 损坏暖瓶的个数 total_bottles = 500 * 6 # 总暖瓶数 total_cost = 1332 # 总运费 unit_cost = 5 # 每 10 个暖瓶的运费 penalty_cost = 10 # 损坏一个暖瓶的赔偿费用

for i in range(total_bottles // 10 + 1): if i * unit_cost + (total_bottles - 10 * i) // 6 * unit_cost == total_cost: damaged = total_bottles - 6 * (total_bottles - 10 * i) // 10 - 10 * i break

print("损坏暖瓶的个数为:", damaged)

用python写某运输队为超市运送暖瓶 500 箱每箱装有 6 个暖瓶。已知每 10 个暖瓶的运费为 5 元损坏一个不但不给运费还要赔 10 元运后结算时运输队共得 1332 元的运费。编程输出损坏暖瓶的个数。注意:用循环语句实现

原文地址: https://www.cveoy.top/t/topic/efyM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录