Can anyone help me with Great Chase from TCS Mockvita 2018 Contest?

Hi Guys can someone tell me how to solve this problem ?

@vijju123 @taran_1407 @vivek_1998299 @meooow @john_smith_3 @aryanc403 @vbt_95

My Approach :
I tried using Extended Euclid’s Algorithm for this but I am not able to solve this problem.

NOTE : This question is not from an ongoing contest. It’s a past contest problem :slight_smile:

Check this out it’ll help

Here is the link to my code


Here is the link to my code

Bro thanks for this one more problem I am facing issues is this one