#C6194. Finding Pythagorean Triplets
Finding Pythagorean Triplets
Finding Pythagorean Triplets
You are given an array of N distinct integers. Your task is to determine whether there exists a Pythagorean triplet (a, b, c) in the array, that is, three numbers that satisfy the equation \(a^2 + b^2 = c^2\). If such a triplet exists, print True
; otherwise, print False
.
Note: The triplet does not need to be ordered in any particular way within the array.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains an integer (N), the number of elements in the array.
- The second line contains (N) space-separated integers representing the elements of the array.
outputFormat
Output a single line to standard output (stdout). Print True
if there exists a Pythagorean triplet in the array; otherwise, print False
.## sample
5
3 1 4 6 5
True