Football rivalry (1)

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 w_(B) that they manage to score,
thus winning the game. Hovewer, with probability 1 − w_(B) 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 w_(M), and they will lose with
probability 1 − w_(M). If they decide to just pass the ball and wait,
eventually the possesion of the ball will go back to team B.

Given w_(B) and w_(M), 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 w_(B) and
w_(M), both between 0 and 1. No given probability is 0.5. The input
cases have no precission issues.

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.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T12:22:22.406Z

© Jutge.org, 2006–2026.
https://jutge.org
