SPOJ 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 $w$ and let $d$ be the probability that a single round results in a draw and $l$ be the probability that Sheldon beats Rajesh in a single round. $w ,\ d ,\ l$ 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.