Football rivalry (1) P99583


Statement
 

pdf   zip

html

Two long-time rival football teams, let us call them B (for beautiful manners) and M (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 B has the ball. If they decide to go all-in, for a direct attack, there is a probability wB that they manage to score, thus winning the game. Hovewer, with probability 1 − wB they will lose the ball while their goal is unprotected, and therefore they will lose. Team B has another option: to just pass the ball around. In that case, the possesion of the ball will eventually go to team M. Then we will have a simmetrical situation: If team M goes for a direct attack, they will win with probability wM, and they will lose with probability 1 − wM. If they decide to just pass the ball and wait, eventually the possesion of the ball will go back to team B.

Given wB and wM, and assuming that both teams take the best decisions (to attack or not to attack) and that team B has the ball now, which is the probability that team B will win?

Input

Input consists of several cases, each with two real numbers wB and wM, both between 0 and 1. No given probability is 0.5.

Output

For every case, print the probability that team B 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