Garage
Time limit2sMemory limit256 MB
Place the fewest axis-aligned w by h garages inside a W by H lot so no additional garage fits without moving them.
- Level
Hard8 of 10
- Topics
- Geometry, Math, Combinatorics
- Solved
- No attempts yet
Problem
Your company has just won a public contract for building a garage complex. Almost all formalities are done, and the contract payment is already in your account.
So now it is the right time to read the contract. There is a sandlot in the form of a rectangle, and you have to place some garages on it. A garage is a rectangle, and its edges must be parallel to the corresponding edges of the sandlot. You may not rotate a garage, not even by . The coordinates of a garage do not have to be integers.
Money must be saved, so you decided to place as few garages as possible. The contract states the opposite requirement: place the maximum possible number of garages.
Here is how that requirement is checked. The plan is accepted if it is impossible to add a new garage without moving the garages already placed. The new garage must also have its edges parallel to the corresponding edges of the sandlot.
Time is money. Find the minimal number of garages you must order, so that you can place all of them on the sandlot and no extra garage fits.
Input
The only line contains four integers , , , : the width and the height of the sandlot and the width and the height of a garage, in meters. You may assume that and .
Output
Print the optimal number of garages.
Note
On an sandlot with a garage, a garage rotated to would still fit, but the contract forbids rotation, so that placement does not count.