Count the number of distinct spanning trees that exist on
Constraints
In test data worth 30% of marks, you may assume
Input Specification
The first line contains a single positive integer,
Each of the next -1
, then there is no degree restriction on vertex
Output Specification
Output the number of distinct spanning trees.
Sample Input
Copy
3
-1
-1
1
Sample Output
Copy
2
Comments
Just read the formula at the end of this link.