Football rivalry (1) P99583


Statement
 

pdf   zip

Two long-time rival football teams, let us call them BB (for beautiful manners) and MM (for 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 go all-in, for a direct attack, there is a probability wBw_B that they manage to score, thus winning the game. Hovewer, with probability 1wB1 - w_B they will lose the ball while their goal is unprotected, and therefore they will lose. Team BB has another option: to just 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 a direct attack, they will win with probability wMw_M, and they will lose with probability 1wM1 - w_M. If they decide to just pass the ball and wait, eventually the possesion of the ball will go back to team BB.

Given wBw_B and wMw_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 with two real numbers wBw_B and wMw_M, both between 0 and 1. No given probability is 0.50.5. The input cases have no precission issues.

Output

For every case, print the probability that team BB will win with four digits after the decimal point. If no goal will be scored, state so.

Public test cases
  • Input

    0.75 0.42
    0 0.23
    0.3 0.60004
    

    Output

    0.7500
    NO GOAL
    0.4000
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++ Python