Time limit1sMemory limit1024 MB
Given N and M, find for each K from 1 to N the expected LCS length of M sequences built by random record draws from 1 to K, modulo 1e9+7.
- Level
Hard9 of 10
- Topics
- Probability, Combinatorics, Math
- Solved
- No attempts yet
Problem
Geunhyeong attends Soongsil University and is also a member of the MatKor club at Korea University. He took the seminar run by MatKor titled <Solve All the Famous LCS Series>.
Geunhyeong wondered whether adding LCS to the number sequence game played by the SCCC club at Soongsil University would be fun. The game works as follows. First, pick a positive integer . Then each of the members who take part performs the following independently.
- A blank sheet of paper is given. Repeat the steps below until is written on the sheet.
- Draw one integer from 1 to inclusive, each with equal probability.
- If the drawn number is larger than every number already on the sheet, write it at the end.
After the game ends, each of the members holds one sequence of length at most . Call these sequences .
Geunhyeong wants the values of , where is the expected length of . Help him find them.
Here is the longest common subsequence of all . A subsequence is obtained by deleting zero or more elements from a sequence without changing the order of the remaining elements.
Input
The first line contains two positive integers and , separated by a space.
Output
Print the expected lengths on the first line, separated by spaces, each reduced modulo .
For an irreducible fraction , its value modulo is defined as , where is the integer satisfying , that is, the modular multiplicative inverse of modulo . If the value is an integer, then , so the result is .
Under the given constraints, the expected value is either an integer or a rational number whose denominator is not a multiple of . This can be proven.