Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Find the Circle

By flash_7 · Limits 3s, 512 MB

You’ll be given two circles A and B of the same radius. You need to draw another circle C such that, C contains both circles A and B completely inside it and the radius of the circle C is minimized. To be specific, after you draw the circle C, there won’t exist any region of circle A or B which lie outside the circle C.


The first line contains an integer T, the number of test cases. Each of the next T lines contains 5 integers X1, Y1, X2, Y2 and R. Here (X1, Y1) is the center of circle A, (X2, Y2) is the center of circle B and R is the radius of both A and B.


1 ≤ T ≤ 50
1 ≤ X1, Y1, X2, Y2, R ≤ 10000


For each test cases, print three decimal numbers X3, Y3 and R3 rounded to two decimal places. Here (X3, Y3) is the center and R3 is the radius of the large circle C.


1 1 9 1 2
5.00 1.00 6.00


In the first sample test case, the center of the circle C is (5.00, 1.00) and the radius is 6.00.



85% Solution Ratio

showmic96Earliest, Jul '18

lliimmFastest, 0.0s

Atiya_143Lightest, 0 B

Hafiz031Shortest, 288B


Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.