shunfurh 于 2017.08.30 00:40 提问
 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 Input2
5 19
50 200
20100
6 2
40 250
20
Sample Output1
54
 caozhy 2017.09.13 23:52
 已采纳