Double Sort
Time limit1.5sMemory limit1024 MB
For a uniformly random n-element subset of 1..m, find the expected final sequence after sorting its positive gaps and taking prefix sums.
- Level
Hard8 of 10
- Topics
- Combinatorics, Probability, Math
- Solved
- No attempts yet
Problem
Given two integers and (), generate a sequence of integers as follows:
- Choose distinct integers between and , inclusive.
- Sort these numbers in non-decreasing order.
- Take the difference sequence, which transforms a sequence into .
- Sort the difference sequence in non-decreasing order.
- Take the prefix sums of the sorted difference sequence to get the final sequence. This transforms a sequence into .
For example, with and :
- Suppose we initially chose , , .
- The sequence in order is , , .
- The difference sequence is , , .
- The sorted difference sequence is , , .
- The prefix sums of the sorted difference sequence are , , .
Suppose the set of distinct integers in step 1 is chosen uniformly at random. Compute the expected value at each position of the final sequence.
Input
The input consists of a single line containing two integers and (, ). Here is the sequence length, and the initial integers are chosen from to inclusive.
Output
Output lines. Each line contains one real number, the expected value at the corresponding position of the final sequence. An answer is accepted if its absolute or relative error is at most .