問題一覧 > 通常問題

No.2953 Maximum Right Triangle

レベル : / AI推定難易度 : 1325 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 101
作問者 : 👑 binap / テスター : 👑 p-adic 👑 hamamu
お気に入りにしたユーザー ProblemId : 11534 / 自分の提出
問題文最終更新日: 2024-11-02 20:01:05
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 452 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。