Marbles problem doubt

sir my factorial function is not working please help

Your code is not running properly because you cannot store numbers greater than 20 factorial, so your factorial function is returning garbage value for numbers greater than that, thus resulting in WA and run time error.
You need to use an implementation of bigInt() class. If you want I can share the code.

sir i dont know how to use bigint. please help me with this

The answer will overflow 64 bits, so you need to use bigInt() here.
Take a look at its implementation here https://github.com/robinrst/HackerBlocks/blob/master/MARBLES.cpp
And here is the working code using bigInt() https://ide.codingblocks.com/s/195884

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.