Practice on Toph

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

Dividing Triangle

By zobayer · Limits 1s, 1.0 GB

You will be given an isosceles right angled triangle. The legs of the triangle have a length of L and lies along the positive X axis and Y axis. You can assume that the coordinates of the three vertices of the triangle are (0, 0), (L, 0) and (0, L).

Your task is to divide the triangle into two sections of equal area by drawing a straight line segment starting from a point on the perimeter to another point on the perimeter of the Triangle.

However, there is a small twist. You cannot just draw the line from any point. You will be given the starting point of the segment on the perimeter. You have to find the coordinate of the other end of that segment.


The first line contains an integer T (T ≤ 1000), the number of test cases. For each test case, there are three integers, L, x, y. Here, L (1 ≤ L ≤ 100000) is the length of the legs, and (x, y) is the coordinate of starting point of the segment.


For each case, print the coordinate of the other end point of the segment. An error lower than 1e-4 will be ignored by the judge. Check sample input and output section for formatting.


250 0 0
250 0 40
125.000000 125.000000
148.809524 101.190476



80% Solution Ratio

sarwarITEarliest, Apr '18

raiyan.sidneFastest, 0.0s

sarwarITLightest, 131 kB

mdvirusShortest, 302B


Login to submit

Related Contests

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