luogu#P2290. [HNOI2004] 树的计数

    ID: 6332 Type: RemoteJudge 1000ms 512MiB Tried: 25 Accepted: 11 Difficulty: 7 Uploaded By: Tags>排列组合数论数学组合数学各省省选2004湖南

[HNOI2004] 树的计数

Problem Description

Consider a tree with nn nodes, denoted v1,v2,,vnv_1, v_2, \ldots, v_n. The degree of node viv_i is given as did_i. How many distinct trees satisfy these conditions?

Input Format

The first line contains a positive integer nn, the number of nodes in the tree. The second line contains nn integers; the ii-th of them is did_i, the degree of node viv_i.

Output Format

Output the number of trees that satisfy the conditions.

4                     
2 1 2 1

2

Hint

Constraints: 1n1501 \le n \le 150. It is guaranteed that the number of valid trees does not exceed 101710^{17}.

Translated by ChatGPT 5