Exchanging coins run error

my code is showing run error for one test case

plz check the code and correct it

problem : https://online.codingblocks.com/app/player/39658/content/77394/5052/code-challenge

code :

plz reply asap

@sengarankit98
hello Ankit,
value of n is very big around 10^9
using array and bottom up approach is not a good idea
a) 10^9 operations will take atleas 10secs which will give tle.
b) u will need 10^9 size array to store all values upto 10^9 which is not possible due to memory restrictions

so use top down approach and map to memoise result of visited state.