No.2953 Maximum Right Triangle
Problem Statement
On the coordinate plane, consider the region $X$ consisting of the boundary and interior of the square formed by the $4$ points $O(0, 0), (D, 0), (D, D), (0, D)$. You are given a point $A = (x, y)$ on the region $X$. Choose a point $B$ from among the lattice points on the region $X$ such that $\angle OAB = 90^\circ$. Find the maximum area of the triangle $OAB$.
It can be shown that the value $S$, which is $2$ times the maximum area of the triangle $OAB$, is always an integer. Output $S$.
If no (non-degenerate) right triangle satisfying the conditions can be formed, output $0$.
This problem has multiple test cases. Answer for each of the $T$ test cases.
Constraints
・ $1 \leq T \leq 100$
・ $1 \leq D \leq 10^9$
・ $0 \leq x, y \leq D$
・ $(x,y) \neq (0,0)$
・All inputs are integers
Input
The input is given from standard input in the following format. $Case_i$ represents the $i$-th test case.
$T$ $Case_1$ $Case_2$ $\vdots$ $Case_T$
Each test case is given in the following format.
$D$ $x$ $y$
Output
For each test case, output the answer on $1$ line.
Sample
Sample 1
Input
3 4 2 1 3 3 3 6 1 1
Output
5 0 2
The figure below illustrates test case $1$. Take $B(1, 3)$. Then $\angle OAB = 90^\circ$ and $\triangle OAB = \frac{5}{2}$. Since this is the maximum area, output $2$ times this value.
For test case $2$, no non-degenerate right triangle $OAB$ can be formed.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
hamamu