Is there any solution for :
i=1 to n ∑ ⌊C/i⌋ = ?
where, Constraints of C and n are : 1 ≤ C,n ≤ 10^9.
I found solution for,
i=1 to n ∑ ⌊C/i⌋ = 2 * ( i=1 to k ∑ ⌊C/i⌋ ) − k^2
where k = ⌊√n⌋ and this solution is correct only for C=n.
Is there any solution exist for C<n in complexity O(sqrt(n)) or O(log(n)) or O(1) ?
$$$\lfloor \frac{C}{i} \rfloor$$$ at most $$$2\times \sqrt{C}$$$ different values.
Prove
$$$i \le \sqrt{C} $$$, $$$\lfloor \frac{C}{i} \rfloor$$$ at most $$$\sqrt{C}$$$ different values.
$$$i \ge\sqrt{C} $$$, $$$\lfloor \frac{C}{i} \rfloor \le \sqrt{C}$$$. so it also at most $$$\sqrt{C}$$$ different values.
This works only for $$$C = n$$$. However, there is a small fix that works (and the complexity remains the same since we just break early):
related task: https://cses.fi/problemset/task/1082/
your task is sum of divisors that is different from mine.
your task is a subtask of the cses problem