Time limit
2s
Memory limit
128 MB
The first k terms of an arithmetic sequence whose first term is x and common difference is d are as follows.
x, x + d, x + 2d, ..., x + (k - 1)d
Here, both x and d are positive integers. Say that a number can be represented if it is the sum of the first k terms of such an arithmetic sequence. Count how many integers from l to r, inclusive, can be represented in this way.
The positive integers l, r, and k are given in this order, one per line.
1 <= l <= r <= 1,000,000,000
2 <= k <= 5
Print the number of integers satisfying the condition.
6 = 1 + 2 + 3, 9 = 2 + 3 + 4 = 1 + 3 + 5, and 12 = 3 + 4 + 5 = 2 + 4 + 6 = 1 + 4 + 7.