Problem Link : http://www.spoj.com/problems/RPSSL/

Prerequisites : Bayes Theorem

Here comes the editorial for previous week’s question as posted on our group.

Let the probability that Rajesh beats Sheldon in a single round be and let be the probability that a single round results in a draw and be the probability that Sheldon beats Rajesh in a single round. can be calculated simply as follows :

Now Rajesh will win the game if he wins two rounds first. The following are the different cases :

Thus we need to sum up all the above cases which result in victory for rajesh. Both the above series can be simplified by using some maths tricks. (Refer to Arithmetico-geometric series.)

The final expression is :

Caution: Check for the cases where d=1.