6.4

initial_costs = [2.5, 2.6, 2.8, 3.1]
salvage_values = [2.0, 1.6, 1.3, 1.1]
maintenance_costs = [0.3, 0.8, 1.5, 2.0]
dp = [[float('inf')] * 2 for _ in range(4)]
dp[0][0] = 0
dp[0][1] = initial_costs[0]
for i in range(1, 4):
dp[i][0] = dp[i-1][0] + maintenance_costs[i-1]
dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + initial_costs[i]
dp[i][1] = initial_costs[i]
min_cost = min(dp[3][0], dp[3][1])
print(f"最优更新策略下的4年内最小总费用为:{min_cost}万元")
print("学号:3022")

posted @ 2024-10-22 17:29  Tsuki*  阅读(3)  评论(0编辑  收藏  举报