Football rivalry (2) P94654


Statement
 

pdf   zip

Two long-time rival football teams, let us call them BB (for beautiful manners) and MM (for miserable — very, very miserable — manners), are playing again. Both teams are exhausted, so the first to score a goal will win the game for sure. At this moment, team BB has the ball. If they decide to attack, there is a probability wBw_B that they manage to score, thus winning the game. Hovewer, with probability B\ell_B they will receive a goal, thus losing the game. With probability 1wBB1 - w_B - \ell_B they will just lose the possesion of the ball. Team BB has another option: to pass the ball around. In that case, the possesion of the ball will eventually go to team MM. Then we will have a simmetrical situation: If team MM goes for an attack, they will immediately win with probability wMw_M, they will immediately lose with probability M\ell_M, and the ball will go back to team BB with probability 1wMM1 - w_M - \ell_M. If they decide to just pass the ball and wait, eventually the possesion of the ball will go back to team BB.

0.55

Given wBw_B, B\ell_B, wMw_M and M\ell_M, and assuming that both teams take the best decisions (to attack or not to attack) and that team BB has the ball now, which is the probability that team BB will win?

Input

Input consists of several cases, each one with four real numbers wBw_B, B\ell_B, wMw_M and M\ell_M between 0 and 1. Assume wB+B1w_B + \ell_B \le 1 and wM+M1w_M + \ell_M \le 1.

  0.45

Output

For every case, print the probability that team BB will win with four digits after the decimal point. (The input cases have no precision issues.) A situation where no goal will be scored (an eternal tie) is similar to a fifty-fifty situation. Consequently, print “0.5000” in this case.

Public test cases
  • Input

    1   0   0.7 0.2
    0.3 0.6 1   0
    0   0   0.3 0.6
    0   0   0.1 0
    0.4 0.2 0   1
    0   1   0.4 0.2
    0.4 0.2 0.4 0.2
    0   0   0   0
    

    Output

    1.0000
    0.3000
    0.5000
    0.0000
    0.6667
    0.3333
    0.5714
    0.5000
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++ Python