Given an integer area, the task is to find the length and breadth of a rectangle with the given area such that the difference between the length and the breadth is minimum possible.
Input: area = 99
Output: l = 11, b = 9
All possible rectangles (l, b) are (99, 1), (33, 3) and (11, 9)
And the one with the minimum |l – b| is (11, 9)
Input: area = 25
Output: l = 5, b = 5
Approach: The task is to find two integers l and b such that l * b = area and |l – b| is as minimum as possible. Factorization can be used to solve the problem but doing just simple factorization from 1 to N will take a long time to get the required output for larger values of N.
To overcome this, just iterate upto . Considering < l ≤ N, then for all values of l, b will always be < .
Below is the implementation of the above approach:
l = 11, b = 9
l = 11, b = 9
Time Complexity: O()
Below is simple implementation.
- Largest subset of rectangles such that no rectangle fit in any other rectangle
- Maximum area of a Rectangle that can be circumscribed about a given Rectangle of size LxW
- Length and Breadth of rectangle such that ratio of Area to diagonal^2 is maximum
- Area of the biggest possible rhombus that can be inscribed in a rectangle
- Sum of Area of all possible square inside a rectangle
- The biggest possible circle that can be inscribed in a rectangle
- Radius of the biggest possible circle inscribed in rhombus which in turn is inscribed in a rectangle
- Maximum area of rectangle possible with given perimeter
- Count the number of rhombi possible inside a rectangle of given size
- Number of squares of side length required to cover an N*M rectangle
- Minimum LCM and GCD possible among all possible sub-arrays
- Find minimum area of rectangle with given set of coordinates
- Minimum squares to cover a rectangle
- Minimum squares to evenly cut a rectangle
- Program for Area And Perimeter Of Rectangle
- Program to find Perimeter / Circumference of Square and Rectangle
- Area and Perimeter of Rectangle in PL/SQL
- Intersecting rectangle when bottom-left and top-right corners of two rectangles are given
- Find two vertices of an isosceles triangle in which there is rectangle with opposite corners (0, 0) and (X, Y)
- Check if any point overlaps the given Circle and Rectangle
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.