Wrong test cases

i am getting three test cases wrong

Hi @mayank10 , your logic is fine , just consider the case when your output is negetive
as when you are computing int A.y=B.x-(a/b)*B.y; you are performing subtraction which might result in negetive values . so, just add this line in your code

System.out.println((getinverse(a)+1000000007)%1000000007);

while printing your result instead of simply executiong System.out.println(getinverse(a));
here i have corrected your code: https://ide.codingblocks.com/s/213782

In case of any doubt feel free to ask :slight_smile:
If you got the answer then mark your doubt as resolved

sir if formula gives the negative result so why the negative answer is wrong

System.out.println((getinverse(a)+1000000007)%1000000007); and what is the logic to add this statement

the above formula is used to take mod of negative numbers, modules operation shouldn’t result in negative number thus we have to make it positive