编程介的小学生 2017-09-27 13:55 采纳率: 20.5%
浏览 858
已采纳

Mission Possible

Problem Description
Mr. Frog loves playing video games. However, it seems that he does not have enough gift in this field, so he often gets stuck in some certain levels. Now this annoying situation comes to him again.

In this mission, Mr. Frog is asked to pass a
dangerous region which is currently under his enemies, control. Every second he is inside this region, his enemies would attack him with everything they have. Luckily, he is wearing a powersuit and still have time to enhance it.

powersuit has three main attributes: health point, velocity and recover speed. In the begin¬ning of this mission, the powersuit has H health points, and is able to move at no faster than Vm/s. Once the health point of powersuit is less than 0, the powersuit would be totally destroyed and Mr. Frog would immediately be killed. At the end of every second that the powersuit still works, the suit would repair itself and recover R health points.

After precise calculation, Mr. Frog has found that, to go through this area, he needs to run at least D meters distance, and every second his enemies, attack would cause A health point loss. Note that attacks take place all the time while the recover only happens at the end of every second, so you can consider that, in every whole second, the powersuit first loses A health points and then recovers R health points at the end of it, if it still works at that moment.

Mr. Frog could enhance his powersuit at any time he wants during the mission. At the beginning all three attributes of his powersuit equals to 0. He needs to pay G1 in order to increase H by 1, while G2 to increase V by 1 and G3 to increase R by 1. For any of these three values, he can only increase it by non-negative integer. For some well-known reasons, Mr. Frog does not want to finish the game too quickly, so you cannot increase the powersuit's speed to more than D m/s. Since you looks so clever, now Mr. Frog wants to know not only how he can finish this mission, but also the way to spend the least money, can you help him?

Input
The first line contains only one integer T, which indicates the number of test cases. For each test case,there are five integers D,A,G1,G2,G3.

Output
For each test case,output one line “Case #x: Ans’’,where x is the case number (starting from 1) and Ans is the minimum cost required to finish the mission.

Sample Input
2
5 1 1 2 5
10 1 1 2 5

Sample Output
Case #1: 7
Case #2: 8

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-15 01:56
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型