This page is still under construction.

Parts of this page are still being built. What you see may change.

Suitcases

Time limit1sMemory limit128 MB

Summary
Given n passengers, k belt suitcases with none yours, and misplacement chance p, compute the chance your suitcase missed the plane.
Level

Medium7 of 10

Topics
Probability, Math
Solved
No attempts yet

Problem

Byteasar has just landed at the Bytetown airport and is waiting for his luggage. Counting Byteasar, nn people flew on this plane, and each of them waits for exactly one suitcase. The suitcases come out onto the conveyor belt in random order.

Bytefly Airlines had an old problem with luggage handling. Suitcases kept disappearing for good. To stop that, the airline introduced a new way of counting suitcases, so every plane now carries exactly as many suitcases as it should. Two suitcases can still be swapped, and then each of them flies with the wrong plane. A single suitcase goes to the wrong city with probability pp.

Since the count always matches, this plane unloads exactly nn suitcases in Bytetown. A suitcase that went to the wrong city is replaced by a stranger's suitcase that reached Bytetown by mistake.

Right now kk suitcases are on the conveyor belt and none of them is Byteasar's. Write a program that finds the probability that Byteasar's suitcase did not arrive in Bytetown with this plane.

Input

The first line contains two integers nn and kk and one real number pp, separated by spaces: the number of passengers, the number of suitcases currently on the belt, and the probability that one suitcase is misplaced. (1≤n≤1 000 0001 \le n \le 1\,000\,000, 0≤k≤n0 \le k \le n, 0≤p≤10 \le p \le 1)

pp is given with at most nine digits after the decimal point.

Output

Print on one line the probability that Byteasar's suitcase did not arrive in Bytetown with this plane, rounded to 12 digits after the decimal point. Write all 12 digits. A value that falls exactly halfway rounds up.

If p=0p = 0, no suitcase can be misplaced, so print 0.000000000000. Print the same value when k=nk = n makes the situation in the statement impossible.

No input leaves the rounding direction of the 12th digit ambiguous.

Examples3

  1. Example 1

    Input
    2 1 0.5
    
    Expected output
    0.666666666667
    
  2. Example 2

    Input
    10 0 0.25
    
    Expected output
    0.250000000000
    
  3. Example 3

    Input
    3 3 0.1
    
    Expected output
    1.000000000000