Can any one Explain this easy Question-Candy Game (Practice icpc) with Solution?

Problem link–
My solution–
How answer is (n*m)??
Thanks in Advance

This falls under a class of problem’s called Gambler’s ruin, look for absorption time in this document on page 9 ( . When the flip has equal probabilities then E[X](where X is expected number of games till game finish) is M*N.

I tried to open the link,its say Error 404 not found

@vivek96 in the url delete ). at end

Or use this


thanks @smsubham & @kaiser123.
Happy Coding!

The logic of the question is not clear …I need to read above link

1 Like