All problems

Exactly 5 Heads in 10 Flips

easyPythonDistributionsBinomial

You've joined the trust-and-safety team at Halfpipe Games, which runs an online board-game site. Every match opens with a virtual coin flipped a fixed number of times, and a player has filed a complaint: they landed on exactly 5 heads out of 10 and are convinced the coin is being nudged so that it looks fair. Support wants one number for the reply - how often does a genuinely fair coin produce a perfect 5-5 split?

The same reply gets written for other games on the site too, and not all of them use a fair coin: some open with a weighted draw, and the session length differs from game to game. Each flip is independent of the ones before it.

Task: Print the probability that exactly the stated number of the session's flips come up heads, as a single number rounded to 4 decimals.

Input

Three lines: how many flips a session has, the probability a single flip comes up heads as a decimal between 0 and 1, and how many heads the player reported. The first and third are whole numbers, and the reported count never exceeds the session length.

Output

One line holding the probability, rounded to 4 decimals and printed the way Python prints a float - 0.2461.

Example:

Input:
10
0.5
5

Output:
0.2461

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…