Waterloo 2025 Fall A - Planting Trees
View as PDFAlice and Ivan, having realized that owning a GPU farm is probably not the best for the environment, have decided to make up for their environmental transgressions by planting trees!
As Alice and Ivan are CS majors, they will not plant any old trees, but instead special unrooted trees with nodes labelled
, such that the degree of every node is an element of the set
.
Being very creative, they name these
-trees.
Alice and Ivan then plant a single mystery seed, which will sprout into any of the -trees with equal probability.
Being inquisitive, but also no longer having a GPU farm at their disposal, they task you to answer the following: for each
, what is the expected number of nodes in their tree with degree
?
Input Specification
The first line of input will have two space-separated integers, (
) and
(
).
The second line of input will have space-separated integers,
.
Output Specification
Output space-separated integers on a single line, the
th of which should equal
,
where
is the expected number of nodes with degree
, as a fraction in lowest terms, i.e.
.
It is guaranteed that the total number of -trees is not a non-zero multiple of
.
Sample Input 1
3 2
1 2
Sample Output 1
2 1
Explanation for Sample Output 1
There is a unique tree, up to relabeling, on 3 vertices whose nodes have degree 2. This is the tree with 2 nodes of degree 1, and 1 node of degree 2.
Sample Input 2
6 2
1 3
Sample Output 2
4 2
Sample Input 3
5 2
1 3
Sample Output 3
0 0
Explanation for Sample Output 3
There are no -trees for
.
Thus the expected number of nodes with degrees 1 and 3 is 0.
Comments