Two Heads in a Row
Back at Whetcode Games, a bonus round triggers only when a player tosses heads on every toss of the round. The designers are weighing up several versions of the rule: some rounds run two tosses, some three, and one prototype swaps the fair coin in the box for a weighted one. Playtesters keep reporting that the bonus "basically never happens", and the designers want the actual figure in front of them for each version before they change anything.
Inside a round the tosses are separate physical events — how one lands has no bearing on the next — and the coin's chance of heads is the same on every toss.
Task: Print the probability that every toss of the round comes up heads, as a plain float with no rounding step.
Input
The first line holds the coin's probability of heads, a decimal number between 0 and 1. The second line holds one integer, the number of tosses in the round, from 1 to 20.
Output
One line holding the probability, printed the way Python prints a float.
Example:
Input:
0.5
2
Output:
0.25
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