Modular GCD wrong Answer

I’m getting wrong answer in this question. Could anyone please tell me what’s wrong in this code?

Qustion : GCDMOD Problem - CodeChef

My code:CodeChef: Practical coding for everyone

Thanks in advance.

CodeChef: Practical coding for everyone
Your solution seems correct , don’t know where it goes wrong .

figured out bro , u have to use 128 bit int integer in your Binary exponentiation

I changes your code and it give AC : “CodeChef: Practical coding for everyone

1 Like

If u don’t wanna use 128 bit integer then u have to do modular multiplication (just like modular exponentiation)

How to avoid overflow in modular multiplication? - GeeksforGeeks

1 Like