#K75882. Pythagorean Triplet Finder
Pythagorean Triplet Finder
Pythagorean Triplet Finder
Given an array of integers, you are to determine whether there exists a triplet \(a, b, c\) in the array such that \(a^2 + b^2 = c^2\). This problem involves basic arithmetic and efficient searching. The formula is given as: \(a^2 + b^2 = c^2\). Your task is to read the input data, process the array, and output True
if such triplet exists; otherwise, output False
.
Note that a triplet consists of three distinct elements (they need not be in any particular order). Ensure that your program reads input from stdin and outputs the result to stdout.
inputFormat
The first line contains an integer \(N\) indicating the number of elements in the array. The second line contains \(N\) space-separated integers representing the array elements.
outputFormat
Output a single line: True
if there exists a triplet \(a, b, c\) in the array that satisfies \(a^2 + b^2 = c^2\), otherwise output False
.
5
3 1 4 6 5
True