#P2612. Wave Intensity Probability
Wave Intensity Probability
Wave Intensity Probability
Amoeba and Little Qiang are good friends. One day, while watching the waves near the sea, Little Qiang got excited by the fierce tide, while Amoeba remained calm as he recalled his past ups and downs in life. This led to a debate between them.
To prove his point, Little Qiang established a model by abstracting the sea surface as a permutation P1…N of numbers from 1 to N. The wave intensity L is defined as the sum of the absolute differences between every two adjacent numbers in the permutation, i.e.,
$$L = |P_2-P_1| + |P_3-P_2| + \ldots + |P_N-P_{N-1}|$$
Given three integers N, M, and K, your task is to compute the probability that a randomly chosen permutation of numbers from 1 to N has a wave intensity L not less than M. The probability should be printed with exactly K digits after the decimal point (rounded half up).
inputFormat
The input consists of a single line containing three space-separated integers:
N
: the size of the permutation.M
: the threshold for the wave intensity.K
: the number of digits to display after the decimal point.
outputFormat
Output the probability that a random permutation has a wave intensity of at least M, formatted with exactly K digits after the decimal point. (Round using standard half-up rounding.)
sample
3 3 4
0.6667