#P6468. Dividing an Isosceles Right Triangle
Dividing an Isosceles Right Triangle
Dividing an Isosceles Right Triangle
Consider an isosceles right triangle in a Cartesian coordinate system with vertices at \(A(0,0)\), \(B(250,0)\) and \(C(0,250)\). The triangle has a right angle at \(A\) and legs of length 250. Thus, its area is \(\frac{1}{2}\times250\times250=31250\). You are given the starting coordinate of a line segment which lies on one of the triangle's sides. You are required to determine the coordinate of the other endpoint (which must also lie on the boundary of the triangle) so that the segment divides the triangle into two regions of equal area (each with area \(15625\)).
The starting point may lie on any of the three sides of the triangle. When the starting point is on side \(AB\) (points of the form \((p,0)\) with \(0<p\le250\)) or on side \(AC\) (points of the form \((0,p)\)), the solution is determined as follows:
- If the starting point is on \(AB\) (i.e. \(P(p,0)\)):
- If \(p\ge125\), choose the endpoint \(Q\) on \(AC\) as \(Q=(0,\frac{31250}{p})\), since the area of triangle \(APQ\) becomes \(\frac{1}{2}p\cdot\frac{31250}{p}=15625\).
- If \(p<125\), choose the endpoint \(Q\) on \(BC\). Parametrize side \(BC\) as \(Q=(250-t,t)\) for \(t\in[0,250]\). The area of triangle \(PBQ\) is \(\frac{1}{2}(250-p)\,t\). Set \(\frac{1}{2}(250-p)\,t=15625\), hence \(t=\frac{31250}{250-p}\), and \(Q=(250-\frac{31250}{250-p},\frac{31250}{250-p})\).
- If the starting point is on \(AC\) (i.e. \(P(0,p)\)) the answer is symmetric:
- If \(p\ge125\), choose \(Q=(\frac{31250}{p},0)\).
- If \(p<125\), choose \(Q=(t,250-t)\) with \(t=\frac{31250}{250-p}\).
If the starting point lies on \(BC\) (i.e. points \(P=(250-t,t)\) with \(0<t<250\)), we treat \(t\) as the parameter:
- If \(t\ge125\), choose \(Q=(250-\frac{31250}{t},0)\) (endpoint on \(AB\)).
- If \(t<125\), choose \(Q=(0,250-\frac{31250}{250-t})\) (endpoint on \(AC\)).
Input: Two real numbers representing the coordinates (\(x\) and \(y\)) of the starting point. It is guaranteed that the point lies on one of the triangle's sides.
Output: Two real numbers representing the coordinates of the other endpoint, accurate to at least two decimal places.
inputFormat
The input consists of two numbers \(x\) and \(y\) separated by space in one line. The point \((x, y)\) lies on one of the triangle's boundary: either on \(AB\) (\(y=0, 0<x\le250\)), or on \(AC\) (\(x=0, 00, y>0\)).
outputFormat
Output two numbers separated by a space: the \(x\) and \(y\) coordinates of the other endpoint of the dividing segment. The answer should ensure that the segment divides the triangle into two regions of equal area.
sample
200 00 156.25