编程介的小学生 2017-08-29 16:40 采纳率: 20.5%
浏览 768
已采纳

Max Damage Export

Consider that there are two kinds of units named Marine and Medic. Each marine has a gun which can create d damage per unit time. And each marine has a health point hp. The medic cannot export any damage, but each medic can heal h health point of the marines per unit time. And her energy is limited. One point of medics' energy can heal one point health point of the marines'. The medics are very clever. If there are m medics, you can consider them as one medic which has m times of healing speed and m times of energy. When a marine is under attack, we consider that the healing and attacking happen at the same time. Any marine's health point cannot exceed hp. Because of the limitation of the supply, the size of your army is limited. You can only create an army containing no more than n people. Of course you will get some enemies, and they will export a damage per unit time to your units. Your enemies will focus on one target each time, which means they will not attack the second marine until the first marine has been killed. After the first one killed, the next one will suffer the rest damage, then the third one. And they will only focus on the units which can export damage, which means that they will not attack the medics. Your enemies have enough reinforcement. So we consider that the damage from the enemies is a certain number a, which will not decrease under your attack.

For example, you have two marines with 5 hp and 4 damage per second, the enemy damage is 10 per second, the total healing speed is 3 per second, like 2 medic with 1.5 healing speed. The damage and healing happen the same time. Actually, we suffer 7 damage per second. After 5 / 7 second, we will lost the first marine. After a second, the total damage will be 5 / 7 * 8 + 2 / 7 * 4. But actually, we do not calculate the damage second by second.

So there comes the problem. As a commander, you should train how many marines and medics in your army to create the most powerful damage under the attack of your enemies.

Input

There are several test cases.
For each test cases:
The 1st line contains one integer n, indicating your supply, the total number of marine and medic.
The 2nd line contains two real number d and h, indicating the damage exporting speed of a marine and the healing speed of a medic.
The 3rd line contains two integer hp and e, indicating the health point of a marine and the energy point of a medic.
The 4th line contains one real number a, indicating the damage from your enemies per unit time.
(1 ≤ n ≤ 100000, 0 < d, h, hp, e, a < 100000).

Output

For each test cases, you should print one line contains one integer, the number of the marine(s) in your army.
Sample Input

2
5 19
50 200
20

100
6 2
40 250
20
Sample Output

1
54

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置