Given n×m big rectangular area with unit squares and k times cut is allowed, the cut should be straight (horizontal or vertical) and should go along the edges of the unit square. What is the maximum possible area of the smallest piece he can get with exactly k cuts.
Input : 3 4 1 Output : 6 Input : 6 4 2 Output : 8
Image for 2nd input
Image for 1st input
As this is n×m rectangular area so there are (n-1) rows and (m-1) columns . So if k > (n + m – 2) then, then cut are not possible . Then, if k is less than that . There will be two cases
- When k is less than max( n, m ) – 1 : In the 1st case, if k is less than max( n, m ) – 1, then either m * ( n / ( k+1 ) ) or n * ( m / ( k+1 ) ) is maximum, here we have divided by ( k + 1) because horizontally or vertically i.e ( m * n = total blocks ) is divided into ( k + 1 ) parts.
- When k is greater than or equal to max( n, m) – 1 : In the 2nd case, if k >= max( n, m ) – 1, then there will be cut on both rows as well as columns so, the maximum possible smallest area will be either m / ( k – n + 2) or n / ( k – m + 2 ) . In this case suppose if n > m then, firstly n-1 (row or column) cut is possible . After that (k – n) cut will be done on m – 1 . So, here we have adjusted this ( k – n ) cut such that smallest possible division should be maximum.
Code – Below is the implementation of the following approach
- Maximum area of quadrilateral
- Maximum area of rectangle possible with given perimeter
- Maximum area of triangle having different vertex colors
- Rectangle with Maximum Area using Java Pair
- Number of squares of maximum area in a rectangle
- Maximum area rectangle by picking four sides from array
- Find maximum volume of a cuboid from the given perimeter and area
- Lexicographically smallest substring with maximum occurrences containing a's and b's only
- Rectangular (or Pronic) Numbers
- Sum of lengths of all 12 edges of any rectangular parallelepiped
- Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
- Minimum number of square tiles required to fill the rectangular floor
- Area of a Hexagon
- Area of Reuleaux Triangle
- Area of plot remaining at the end
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.