Exchanging coins dp

getting run error and tle on submission
please help

https://ide.codingblocks.com/s/44512

https://hack.codingblocks.com/contests/c/512/721

Run-time error is because range of N is 10^9, and vector size if 10^8.
TLE is due to initialisation of vector of so large size.

Try some other approach because it wont be possible to take a vector of size 10^9.

HINT:
Think in this direction that you can not compute answer for N=10^9, but you can easily solve this problem if N=10^8. This is because we can make a global array of size 10^8 easily.

So, can recurrence be reduced to something which contains terms of N/i and i>=10 lets say.

https://ide.codingblocks.com/s/44529

Here is my solution for your referrence.