 Last super-last one

Professor Oak is very strict. However, his two nieces are not aware of
this fact. So, when he says “últim” (Catalan word for “last one”), this
means in practice “not the last time” (that his nieces are doing
whatever they are doing). When he says “superúltim”, this means “maybe
the last time” (with probability ℓ₁, typically small). And when he says
“últimsuperúltim”, this also means “maybe the last time” (but with
probability ℓ₂ > ℓ₁).

Supose that Prof. Oak says “últim”, “superúltim” and “últimsuperúltim”
with independent probabilities p₁, p₂ and p₃ = 1 − p₁ − p₂,
respectively, until their nieces stop. How many phonemes will Prof. Oak
need to say on the average? Take into account that, for all those
Catalan words, each letter corresponds to one phoneme.

Input

Input consists of several cases, each one with the probabilities ℓ₁, ℓ₂,
p₁ and p₂. Assume 0 < ℓ₁ < ℓ₂ ≤ 1, 0 ≤ p₁ < 1, 0 ≤ p₂ ≤ 1, and
p₁ + p₂ ≤ 1.

Output

For every given case, print with three digits after the decimal point
the expected number of phonemes said by Prof. Oak. The input cases do
not have precision issues.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T12:09:05.872Z

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