#abc303h. Ex - Constrained Tree Degree
Ex - Constrained Tree Degree
Score : points
问题描述
给定一个整数 和一个包含整数的集合 ,其中所有元素均在 到 的范围内。
求满足以下条件的、具有 个顶点(编号为 至 )的树 的个数,对 取模:
- 对于所有 ,顶点 在树 中的度数 都属于集合 。
以上为通义千问 qwen-max 翻译,仅供参考。
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 .
Sample Input 1
4 2
1 3
Sample Output 1
4
A tree satisfies the condition if the degree of one vertex is and the others' are . Thus, the answer is .
Sample Input 2
10 5
1 2 3 5 6
Sample Output 2
68521950
Sample Input 3
100 5
1 2 3 14 15
Sample Output 3
888770956
Print the count modulo .
update @ 2024/3/10 08:32:45