Problem list
Log in
#icpc00325 · ICPC BAPC 2019

Lucky Draw

Platinum II 2.0 s 2048 MB

You and your friends at the Betting against All Probability Club are visiting a casino where the following game is played.

Each of the $n$ players starts with $k$ lives and puts in a fixed amount of money. In each round of the game, each player flips a biased coin and loses a life if she gets tails. The game ends when only one player remains, in which case this person wins, or ends in a draw if all remaining players lose their last life in the same round. If there is a winner, she wins $n$ times her original bet. In case of a draw, no one wins anything.

Being a BAPC member you quickly realize the casino has an edge here: whenever the game ends in a draw all of the contestants lose the money they bet. You are now wondering what exactly is the probability that this game ends in a draw, so you can figure out how much the casino profits on average.

Input

  • One line containing two integers, $2\leq n\leq 50$, the number of players, $1\leq k\leq 50$, the number of lives each player has, and a floating point number $0.1 \leq p \leq 0.9$, the probability the coin lands heads.

Output

  • Output a single floating point number: the probability of the game ending in a draw. Your answer should have an absolute error of at most $10^{-6}$.

Example 1

Input
2 2 0.5
Output
0.185185185

Example 2

Input
2 2 0.8
Output
0.056241426

Example 3

Input
5 3 0.85
Output
0.045463964
Source
ICPC BAPC 2019
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code