luogu#P4863. JerryC Loves Driving
JerryC Loves Driving
Background
JerryC has recently become obsessed with Asphalt Racing.
Problem Description
As everyone knows, JerryC is a crazy Female. He recently bought a sports car (but he does not have a driver’s license), so he can only practice driving in a remote place.
Of course, JerryC is not going to drive normally. She first decides to drive segments of road. In the -th segment, the speed starts accelerating from . Each second, it increases by unit of speed. When the speed reaches , JerryC will reduce the speed back to , and then start the next segment.
For the -th second of the -th segment, the pleasure value JerryC gets is $\left\lfloor \frac{i+A-1}{j} \right\rfloor \times (-1)^j$. (Anyway, JerryC just does not like odd numbers.)
Now please compute JerryC’s final total pleasure value.
P.s.:
If you did not understand the above, then the simplified version is:
Given , compute the value of the following expression.
$$\sum_{i=A}^B \sum_{j=1}^{i}\left\lfloor \frac{i}{j} \right\rfloor \times (-1)^j$$Input Format
One line with two positive integers .
Output Format
One line with one integer, representing the final pleasure value.
1 1
-1
2 2
-1
3 3
-3
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5