Number of largest circles that can be inscribed in a rectangle
Given two integers L and B representing the length and breadth of a rectangle, the task is to find the maximum number of largest possible circles that can be inscribed in the given rectangle without overlapping.
Input: L = 3, B = 8
From the above figure it can be clearly seen that the largest circle with a diameter of 3 cm can be inscribed in the given rectangle.
Therefore, the count of such circles is 2.
Input: L = 2, B = 9
Approach: The given problem can be solved based on the following observations:
- The largest circle that can be inscribed in a rectangle will have diameter equal to the smaller side of the rectangle.
- Therefore, the maximum number of such largest circles possible is equal to ( Length of the largest side ) / ( Length of the smallest side ).
Therefore, from the above observation, simply print the value of ( Length of the largest side ) / ( Length of the smallest side ) as the required result.
Below is the implementation of the above approach:
Time Complexity: O(1)
Auxiliary Space: O(1)