#P5249. Gatling Roulette Survivor

    ID: 18485 Type: Default 1000ms 256MiB

Gatling Roulette Survivor

Gatling Roulette Survivor

In this problem, n long‐necked deer (players) are sitting around a circular table and are numbered from 1 to n in increasing order. They play a dangerous game of Gatling Roulette. The game proceeds in turns. Starting with deer 1, each surviving deer takes a turn. On a deer’s turn, it points a state-of‐the‐art gatling at its own head and pulls the trigger. The probability of being shot is P0 and the probability of surviving is 1-P0. If a deer gets shot, it is immediately eliminated from the game, and the next surviving deer takes the next turn. This process continues indefinitely until only one deer remains; that deer is declared the winner.

Special rule: If P0 = 0, then deer 1 is declared the winner by definition.

Given the values of P0, n, and an index k (1 ≤ k ≤ n), determine the probability Pk that deer number k will be the sole survivor.

Note: Even though many turns may pass without any elimination (when the current deer survives), eventually an elimination occurs. Thus, if you observe only the elimination events, the order in which the deer get eliminated is determined by a biased cyclic process. In this problem you are to compute the eventual survival probability by accounting for all these possibilities.

inputFormat

The input consists of a single line containing three values: P0 (a floating–point number), n (an integer representing the total number of deer), and k (an integer, the index of the deer for which the survival probability is to be computed).

It is guaranteed that 1 ≤ k ≤ n, and n ≥ 1.

outputFormat

Output a single floating–point number, which is the probability that the k–th deer becomes the sole survivor. Your answer should be accurate to at least 6 decimal places.

sample

0 5 1
1.000000