Meaning
is to seek arithmetic progression or
X represents the first item, Y represents the last item, and z indicates what the tolerance does.
Arithmetic progression and, I will! (first + last item) * Number/2
But that's not the problem.
Because of the specificity of different or, so we can one to consider
We define a function f (a,b,c,n) f (a,b,c,n) to denote that the first item is a, the tolerance is b b, c c is a divisor, n n is the number of items and
For the first I, the last one is called the No. 0 digit, from right to left
All we need to know is parity of f (X,z,2i,⌊ (y−x)/z⌋+1) F (X,z,2^i,\lfloor (y-x)/z \rfloor + 1)
So we decided to use the simplest and most brutal way, that is to sum.
The equivalence we are asking now is the same as the following equation
∑i=0n−1⌊x+z∗ic⌋\sum_{i=0}^{n-1}\lfloor \frac{x+z*i}{c} \rfloor
Obviously, the equation can become the following one
∑i=0n−1⌊xc⌋ (⌊zc⌋i) ⌊x%c+z%c∗ic⌋\sum_{i=0}^{n-1}\lfloor\frac{x}{c}\rfloor (\lfloor\frac{z}{c}\rfloor i) \lfloor \ FRAC{X\%C+Z\%C*I}{C} \rfloor
So the first two parts, we can even come out at the beginning, it doesn't matter.
Then the only thing left is the one behind.
∑i=0n−1⌊x%c+z%c∗ic⌋\sum_{i=0}^{n-1}\lfloor \frac{x\%c+z\%c*i}{c} \rfloor
So how to ask for it.
We can think of him as a about I, The Intercept is ⌊x%cc⌋\lfloor \frac{x\%c}{c} \rfloor, the slope is ⌊z%c