Author: | A. Usmanov, L. Verkhovtsev. Translation: A. Logutova. | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 256 Mb | |
Output file: | Standard output |
Leonid is an astronaut. His spaceship crashed on far unknown planet, full of natural resources. Leonid couldn't repair his spaceship, therefore he stayed on the planet. Many years later he achieved fantastic progress in planet exploration — he built an ore mining and processing mill.
The mill works in several stages:
1. N drills mine the ore. The speed of one drill is UN kilograms per hour;
2. The ore gets to melting furnaces. The speed of one furnace is UK kilograms per hour;
3. After furnaces, plates get to M machine-tools. The speed of one machine-tool is UM kilograms per hour.
Leonid's mill pollutes the planet. This pollution disturbed inhabitants of the planet. Fictional arthropods have broken all furnaces.
Leonid is planning to build new furnaces and to renew manufacture. But at first he wants to calculate an optimal number of furnaces. We will call "surplus" the total quantity of the ore and plates, which is waiting for the processing. The number of furnaces is optimal if the surplus is minimal for the fixed period of time.
Help Leonid to calculate optimal number of furnaces. Obviously, Leonid wants to renew manufacture as fast as possible. Therefore among all possible answers, you should choose the minimal one.
The first line contains two integers N and M — the number of drills and machine-tools respectively.
The second line contains three integers UN, UK and UM — the speeds of one drill, one furnace and one machine-tool respectively.
Print an integer — optimal number of furnaces.
If there are several possible answers, choose the minimal one.
1 ≤ N, M, UN, UK, UM ≤ 109
Let's consider first test. Let's fix the period of time — T = 10 hours. Amount of produced resources is shown in the table.
Number of furnaces | Mined ore, kg | Melted ore, kg | Surplus ore, kg | Processed plates, kg | Surplus plates, kg | Surplus ore and plates, kg |
---|---|---|---|---|---|---|
1 | 100 | 30 | 70 | 30 | 0 | 70 + 0 |
2 | 60 | 40 | 60 | 0 | 40 + 0 | |
3 | 90 | 10 | 70 | 20 | 10 + 20 | |
4 | 100 | 0 | 70 | 30 | 0 + 30 |
Surpluses are equal for three and four furnaces, which means that three furnaces is enough.
No. | Standard input | Standard output |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|