Problems > Cayley's Forest > Editorial

Cayley's Forest — Solution & Editorial

Back to the Problem

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)