AlgoWiki

Floor sum

Sums of the form

∑i=1n⌊pi+qr⌋\sum_{i=1}^n \left\lfloor \frac{pi+q}{r} \right\rfloor

can be evaluated in O(log⁡n)O(\log n) time. See Summation of Floor Function Series for a special case.

Problems