Pythagoras triplet wrong test cases

wrong answer in last 2 test cases
i have checked all triplets and even printed -1 for triplets below 3,4 & 5
THIS IS THE CODE BELOW:

Aayush plz send your code by saving on ide only

I have added the link now…pls check

Aayush, your code is not producing correct output for following type of test case : 24
Your output : 7 25
Expected output : 143 145
Just calculate the following values, and there is no need to use loop conditions till n, as it will increase your time complexity
For n to be odd
p=(n+1)/2;
q=(n-1)/2;
a=(p+q)(p-q);
b=2
pq;
c=(p
p)+(q*q);

For n to be even :
p=n/2;
q=1;
a=(p+q)(p-q);
b=2
pq;
c=(p
p)+(q*q);

This was my first approach but it also gave 3 wrong test cases…then i read the question again and it said one of the 2 legs of a pythagorean triangle is given …thats why i thought 24 shoud give 7 and 25

i submitted 1st method again and still it has 2 wrong test cases…

Ok i got it…i changed int to long int because the calculations took it out of range and it worked…
THANKS