Cayley's Forest — Solution & Editorial
Cayley's formula: there are NN−2 labelled trees on N vertices (with N = 1 and N = 2 both giving 1). Fast exponentiation for large N.
Complexity: O(log N)
Cayley's formula: there are NN−2 labelled trees on N vertices (with N = 1 and N = 2 both giving 1). Fast exponentiation for large N.
Complexity: O(log N)