#C2357. Right Triangle Checker
Right Triangle Checker
Right Triangle Checker
You are given three positive integers representing the lengths of the sides of a triangle. Your task is to determine whether these sides can form a right triangle.
A triangle is a right triangle if the square of the length of the longest side equals the sum of the squares of the lengths of the other two sides, i.e. in mathematical notation, if the sides (after sorting) satisfy the equation:
\(a^2 + b^2 = c^2\)
You need to process multiple test cases. For each test case, read three integers from stdin and output YES
if they form a right triangle, otherwise output NO
. Each result should be printed on a new line.
inputFormat
The first line contains an integer T
representing the number of test cases. Each of the following T
lines contains three space-separated integers a
, b
, and c
, representing the sides of a triangle.
outputFormat
For each test case, output a single line containing YES
if the given sides form a right triangle, or NO
otherwise.
4
3 4 5
5 12 13
1 1 1
6 8 10
YES
YES
NO
YES
</p>