#C1472. Count Pythagorean Triplets
Count Pythagorean Triplets
Count Pythagorean Triplets
Given an array of integers, you are required to determine the number of distinct triplets (a, b, c) from the array that satisfy the Pythagorean theorem, i.e., \(a^2 + b^2 = c^2\). Each triplet should be counted only once regardless of the order of the numbers.
Note that the integers in the array can be provided in any order, and the same number may be used in different triplets if it appears only once in the array. For instance, if the triplet (3, 4, 5) forms a Pythagorean triplet, it should be counted exactly once even if the numbers are permuted.
The problem requires reading input from stdin and printing the result to stdout.
inputFormat
The input consists of two lines:
- The first line contains a single integer \(n\), representing the number of elements in the array.
- The second line contains \(n\) space-separated integers.
outputFormat
Output a single integer representing the number of distinct Pythagorean triplets that can be formed from the array.
## sample5
3 1 4 6 5
1