编程介的小学生 2017-08-25 02:57 采纳率: 20.5%
浏览 709
已采纳

Dr. Zomboss's Revenge

These days MM is interested in the final stage of Plants vs Zombies, called "Dr. Zomboss's revenge".

In this stage, MM is provided with an empty map with n rows and m columns as well as n*m plants. MM is required to fill the map with these n*m plants, which come from t different kinds.

However, the terrible fact is that, Dr. Zomboss will randomly throw a fire ball to squash MM's precious plants. A fire ball will be randomly placed on any row, squashing an entire row of plants. For instance, for a map with 5 rows and 4 columns, the possibility of squashing the first row is 1/5.

MM has been accustomed to the inevitable squashing. What he cannot bear is that many plants of the same kind might be squashed at the same time. For each kind of plants, namely the ith (1 ≤ i ≤ t) kind, if the number of plants squashed is less or equal than bi, called the bearing factor, MM won't care. However, for every additional plant (compared to bi) with the ith kind squashed, MM will get his angry value increased by ai, called argry factor.

Now, MM needs to find a way to place his plants which can minimize the expectation of this total angry value and he asked you to tell him what the minimum expectation is.

Notice that the initial angry value of MM is 0.

Input

There are multiple cases. The first line of each case contains three integers n (1 ≤ n ≤ 10), m (1 ≤ m ≤ 10), t (1 ≤ t ≤ 30), as described above.
Each of the following t lines contains three integers discribing a kind of plant: the number of plant ci (1 ≤ ci ≤ n*m), the bearing factor bi (1 ≤ bi ≤ ci)and the angry factor ai (1 ≤ ai ≤ 100).
We assert that the sum of ci equals to n*m. Process to the end of file.

Output

For each test case, output the minimium mathmetical expectation in a single line, rounded to 3 digits after the decimal point.
Sample Input

2 3 2
3 1 1
3 2 2
Sample Output

0.500

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-08-27 15:34
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答