atcoder#ABC303H. [ABC303Ex] Constrained Tree Degree
[ABC303Ex] Constrained Tree Degree
Score : points
Problem Statement
You are given an integer and a set consisting of integers between and .
Find the number, modulo , of trees with vertices numbered through such that:
- for all , where is the degree of vertex in .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the number, modulo , of the conforming trees .
4 2
1 3
4
A tree satisfies the condition if the degree of one vertex is and the others' are . Thus, the answer is .
10 5
1 2 3 5 6
68521950
100 5
1 2 3 14 15
888770956
Print the count modulo .