Masha wants to wallpaper a wall without windows and doors that is $$$a$$$ centimeters long and $$$h$$$ centimeters high. Masha has already chosen beautiful wallpaper with a pattern, and now she needs to calculate how many rolls to buy.
Each roll has a width of $$$m$$$ centimeters and a length of $$$s$$$ centimeters. The wallpaper has a pattern that repeats every $$$k$$$ centimeters along the roll.
The process of wallpapering proceeds as follows. A strip of length $$$h$$$ is cut from the roll, which will be glued to the wall vertically from floor to ceiling. Then the next strip is cut for gluing next to it, and so on. However, it is not that simple! To make it look nice, the pattern on the next strip must align with the pattern on the previous one. To achieve this, it may be necessary to first cut off an extra piece of the roll (which will have to be discarded) before cutting the next strip.
The illustration shows an example. Two strips have been cut from a long roll for gluing. After cutting the first strip, an additional piece had to be cut from the roll (shown crossed out) so that the pattern on the next strip starts exactly the same as on the previous one.
Note that horizontal seams on walls look bad, so the length of the glued strip must always be strictly equal to the height of the room $$$h$$$. If the last glued strip turns out to be wider than the remaining length of the room, it can be cut lengthwise. Also, note that all rolls in the store are absolutely identical.
Determine how many rolls of wallpaper Masha needs to buy to have enough to wallpaper the wall without taking extra rolls.
Five integers are given in five lines: $$$a$$$ — the length of the wall, $$$h$$$ — the height of the wall, $$$k$$$ — the length of the pattern period, $$$m$$$ — the width of the wallpaper roll, $$$s$$$ — the length of the roll.
Constraints: $$$1 \leq a, m, s \leq 2*10^9$$$, $$$1 \leq h \leq s$$$, $$$1 \leq k \leq s$$$.
Output a single integer — the minimum number of rolls of wallpaper required to wallpaper the wall.
Solutions that work correctly under the additional constraint $$$a, m, s \leq 1000$$$ will score at least 50 points.
933320
1
54128
2