C.C, a 9th
grade student, dreams of finishing school and getting a job working for his
father's company, a paper, advertising and billboard ads company. For start
he was promised a position in the "Cardboards" department and he has
rectangular pieces of cardboard of different sizes waiting for him there, from
which he has to make smaller rectangular pieces of cardboard, by cutting the
big ones with a mechanical device called a guillotine.
In order to be promoted head of the "Cardboards" department he has
to solve a cutting process design problem: for a rectangular piece of cardboard
of sizes L and H
which are given the task is to find a cutting method using the guillotine so
as to obtain the maximum number of rectangular pieces of cardboard of sizes
A and B
which are also given. What is known is that the accepted technology involves
placing the initial rectangle in any position, cutting it into horizontal rectangular
strips of various widths and then cutting each strip, using parallel cuts, into
smaller rectangles.
Task
Determine the maximum number of cardboard pieces that can be obtained using this technology from the initial piece of cardboard while knowing sizes L and H of the initial piece of cardboard and sizes A and B of the pieces of cardboard ordered by the client..
Input Data
Input file cartonase.in contains on the first line two positive integers L H, separated by a space, representing the sizes of the initial piece of cardboard. The second line contains two positive integers A and B separated by a space, representing the sizes of each of the ordered pieces of cardboard.
Output Data
Output file cartonase.out will contain one line with a single number representing the maximum number of pieces of cardboard that can be obtained.
Constraints and Statements
cartonase.in | cartonase.out | Explanation |
35 20 9 12 |
5 |
We place the rectangle on its "height", cut 4 horizontal strips (one strip of nine, two of 12 and one of 2); the first strip is cut into two pieces (of 12 and of 8) and the other two strips are each cut in 3 pieces (two of 9 and one of 2). This way we obtain 5 pieces of cardboard. |
Time limit: 0.1 seconds/test
prof. Rodica Pintea
Bucharest "Grigore Moisil" High-School
Contact:ro_dica@yahoo.com