CSES - Sum of Divisors

Author: Benjamin Qi

Our goal is to compute the summation i=1nnii\sum_{i=1}^n\left\lfloor \frac{n}{i}\right\rfloor\cdot i in faster than Θ(n)\Theta(n) time.

Hint

Solution

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!