#K40167. Finding a Pythagorean Triplet
Finding a Pythagorean Triplet
Finding a Pythagorean Triplet
Given a list of n integers, determine whether there exist three distinct elements a, b, and c in the list such that the equation \(a^2 + b^2 = c^2\) holds. This equation represents a Pythagorean triplet in which the square of one element is equal to the sum of the squares of the other two elements.
Your task is to implement a program that reads an integer n
followed by n
integers from standard input, and prints True
if a Pythagorean triplet exists, or False
otherwise.
inputFormat
The first line of input contains an integer n
(the number of elements). The second line contains n
space-separated integers.
outputFormat
Print True
if there exists a Pythagorean triplet \(a^2 + b^2 = c^2\), otherwise print False
.
5
3 1 4 6 5
True