Given a circular sheet of radius R and the task is to find the total number of rectangles with integral length and width that can be cut from the circular sheet, one at a time.
Input: R = 2
8 rectangles can be cut from a circular sheet of radius 2.
These are: 1×1, 1×2, 2×1, 2×2, 1×3, 3×1, 2×3, 3×2.
Input: R = 1
Only one rectangle with dimensions 1 X 1 is possible.
Consider the following diagram,
Its easy to see, that ABCD is the largest rectangle that can be formed in the given circle with radius R and centre O, having dimensions a X b
Drop a perpendicular AO such that, ∠AOD = ∠AOB = 90°
Consider the following diagram for further analysis,
Consider triangles AOD and AOB, In these triangles, AO = AO (Common Side) ∠AOD = ∠AOB = 90° OD = OB = R Thus, by SAS congruence ▵AOD ≅ ▵AOB ∴ AD = AB by CPCT(i.e Corresponding Parts on Congruent Triangles) or, a = b => The rectangle ABCD is a square
The diameter BD is the maximum diagonal the rectangle can have to be able to be cut from the Circular Sheet.
Thus, all the combinations of a and b can be checked to form all possible rectangles, and if the diagonal of any such rectangle is less than or equal to the length of the diagonal of the largest rectangle formed (i.e 2 * R, where R is the Radius of the circle as explained above)
Now, the maximum length of a and b will always be strictly less than the diameter of the circle so all possible values of a and b will lie in the closed interval [1, (2 * R – 1)].
Below is the implementation of the above approach:
8 rectangles can be cut from a circle of Radius 2
Time Complexity: O(R2), where R is the Radius of the Circle
- Radii of the three tangent circles of equal radius which are inscribed within a circle of given radius
- Find area of the larger circle when radius of the smaller circle and difference in the area is given
- Radius of the circle when the width and height of an arc is given
- Equation of circle from centre and radius
- Find minimum radius such that atleast k point lie inside the circle
- Angular Sweep (Maximum points that can be enclosed in a circle of given radius)
- Length of the chord of the circle whose radius and the angle subtended at the center by the chord is given
- Radius of the biggest possible circle inscribed in rhombus which in turn is inscribed in a rectangle
- Number of rectangles in N*M grid
- Number of unique rectangles formed using N unit squares
- Number of common tangents between two circles if their centers and radius is given
- Count the number of rectangles such that ratio of sides lies in the range [a,b]
- Find the number of rectangles of size 2*1 which can be placed inside a rectangle of size n*m
- Program to calculate area of inner circle which passes through center of outer circle and touches its circumference
- Check if a circle lies inside another circle or not
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.