(a,b,c) is a pythagorean triplet you are given b and b is even and you have to find a and c and output maximum sum of triplet (a+b+c),
Let us consider n as a number.
4 * n^2 = 4 * n^2 ( multiply 4 both side) = ( n^2 + 1 )^2 - ( n^2 - 1 )^2 ( n^2 - 1 )^2 + ( 2 * n )^2 = ( n^2 + 1 )^2 a^2 + b^2 = c^2 a = n^2 - 1 b = 2 * n c= n^2 + 1 sum=a+b+c; =n^2 - 1 + b + n^2 + 1 =2*n^2+b (n=b/2) =(b^2 / 2 )+b
using namespace std;
long long T;
cin>>T;//input T testcases
long long b;
cin>>b;//taking input b which is even