Suitcases
Time limit1sMemory limit128 MB
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, 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 .
Since the count always matches, this plane unloads exactly 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 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 and and one real number , separated by spaces: the number of passengers, the number of suitcases currently on the belt, and the probability that one suitcase is misplaced. (, , )
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 , no suitcase can be misplaced, so print 0.000000000000. Print the same value when makes the situation in the statement impossible.
No input leaves the rounding direction of the 12th digit ambiguous.