Not all test cases running

Sir/mam, I have initialised the number with long long and after that also my test cases are acceptable. Can someone please help me out with this?


My code

Hey Lakshay! When you are initialising m and n in line 11,12,26,27 of your code, you should declare those variables with long long as well because in lines 13,14,15 and 28,29,30 you are multiplying them which can result in overflow. Try this first and let me know if there is any problem.

already did that but still one test case is wrong.

The issue in your code is that you are printing the wrong variables, look I have added comments in your code to explain it properly where you made mistake.

1 Like

Kindly resolve this question and also rate the response if my correction makes sense to you, helps me a ton!

But one thing I need to ask is that our a = mm - nn, b=2mn, c=mm+nn. So, why are we printing a for 2mn?

1 Like

Let us take a test case where your earlier code was failing to get a sense of grasp, for eg: if n is given to us as 6, since it is even, then by n = 2mn, we get m = 3, now we have to find the other 2 sides because we already have one of our side as 2mn i.e 6 and we know that the other 2 sides are either a or c, and since c is the hypotenuse we will have to print a first. So the pair we will get is 8,10 but in your earlier code it was printing 6,10 which means it was printing the already given number again and missing 8. Hope, now Iā€™m making sense!

1 Like