1066排队接水
需要让平均等待时间最小也就是需要让总等待时间最小。我们可以让每一个时刻等待的人数最少。显然我们让耗时少的人先打水可以使得答案最优。
水壶大喝不上水石锤(滑稽
1067最大整数
显然是要将整数从高到低位排序的,但是我们考虑这种情况:
63 637
63 631
发现这时不好排序,我们需要让较短的数与较长的数字循环比较。
使用sprintf好写多啦!
1076美元汇率
我们定义dp数组f
(f_{i0}) 表示在第 (i) 天最多的手持美元数量
(f_{i1})表示在第 (i) 天最多的手持马克数量
可以得到转移方程( (a) 表示汇率)
[f[i][0] = max(f[i-1][0],100.0*f[i-1][1]/a[i])
]
[f[i][1] = max(f[i-1][1],a[i]*f[i-1][0]/100.0)
]