Problem 2872 · Hard

Maximum Number of K-Divisible Components

Process a tree bottom-up and cut off every subtree whose total is divisible by k, passing other totals upward.

Open the interactive visualisation