提交时间:2024-12-24 15:15:19
运行 ID: 50563
# 输入重量和是否加急 weight = int(input()) urgent = input() # 基本费用 base_cost = 8 # 如果重量超过1000克,计算超重费用 if weight > 1000: # 计算超过1000克的部分 extra_weight = weight - 1000 # 每500克加收超重费4元,不足500克部分按500克计算 extra_cost = (extra_weight // 500 + (1 if extra_weight % 500 > 0 else 0)) * 4 else: extra_cost = 0 # 如果选择加急,多收5元 if urgent == 'y': extra_cost += 5 # 总费用是基本费用加上超重费用 total_cost = base_cost + extra_cost # 输出邮费 print(total_cost)