Maximum given sized rectangles that can be cut out of a sheet of paper | Java implementation of the approach ; Function to return the maximum rectangles possible ; Cut rectangles horizontally if possible ; One rectangle is a single cell ; Total rectangles = total cells ; Cut rectangles vertically if possible ; Return the maximum possible rectangles ; Driver code
class GFG { static int maxRectangles ( int L , int B , int l , int b ) { int horizontal = 0 , vertical = 0 ; if ( l <= L && b <= B ) { int columns = B / b ; int rows = L / l ; horizontal = rows * columns ; } if ( l <= B && b <= L ) { int columns = L / b ; int rows = B / l ; vertical = rows * columns ; } return Math . max ( horizontal , vertical ) ; } public static void main ( String [ ] args ) { int L = 10 , B = 7 , l = 4 , b = 3 ; System . out . print ( maxRectangles ( L , B , l , b ) ) ; } }