Groups
Category
The floor sum computes S(n,m,a,b) = sum_{i=0}^{n-1} floor((a i + b)/m) efficiently in O(log(min(a,m))) time.
Digit DP is a dynamic programming technique for counting or aggregating values over all integers in a range that satisfy a digit-based property.