Find the radius of the circles which are lined in a row, and distance between the centers of first and last circle is given
Given here are n circles which touch each other externally, and are lined up in a row. The distance between the centers of the first and last circle is given. The circles have a radius of equal length. The task is to find the radius of each circle.
Input: d = 42, n = 4 Output: The radius of each circle is 7 Input: d = 64, n = 5 Output: The radius of each circle is 8
Suppose there are n circles each having radius of length r.
Let, the distance between the first and last circles = d
From the figure, it is clear,
r + r + (n-2)*2r = d
2r + 2nr – 4r = d
2nr – 2r = d
so, r = d/(2n-2)
The radius of each circle is 7
Time Complexity: O(1)
Auxiliary Space: O(1)
My Personal Notes arrow_drop_up
Please Login to comment...