Given an integer C, the task is to find all possible pairs (A, B) in range [1, C) such that:
- A2 + B2 = C2
- A < B
Input: C = 5
(3)2 + (4)2 = 9 + 16 = 25 = 52
Input: C = 25
Output:(15, 20), (7, 24)
Explanation: Both the pairs satisfy the necessary conditions.
- Check all possible values of A and B in the range [1, C).
- Store all pair that satisfies the given conditions.
Below is the implementation of the above approach:
Time Complexity: O(C2)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Forming smallest array with given constraints
- Forming triangles using points on a square
- Pythagorean Triplet with given sum
- Generate Pythagorean Triplets
- Check if a number is a Pythagorean Prime or not
- Pythagorean Triplet with given sum using single loop
- Twin Pythagorean triplets in an array
- Sort decreasing permutation of N using triple swaps
- Ways to form n/2 pairs such that difference of pairs is minimum
- Summation of GCD of all the pairs up to N
- Sum of bit differences among all pairs
- Count pairs with Odd XOR
- Count pairs with given sum | Set 2
- Count pairs (i,j) such that (i+j) is divisible by A and B both
- Number of pairs such that their HCF and LCM is equal
- Find all Pairs possible from the given Array
- Count pairs from 1 to N such that their Sum is divisible by their XOR
- Count of pairs from 1 to a and 1 to b whose sum is divisible by N
- Find the maximum possible value of a[i] % a[j] over all pairs of i and j
- All pairs whose xor gives unique prime
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : GauravRajput1