P4863 JerryC Loves Driving

Background

JerryC has recently become obsessed with Asphalt Racing.

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 $(B-A+1)$ segments of road. In the $i$-th segment, the speed starts accelerating from $1$. Each second, it increases by $1$ unit of speed. When the speed reaches $(i+A-1)$, JerryC will reduce the speed back to $1$, and then start the next segment. For the $j$-th second of the $i$-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 $A, B$, 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 $A, B$.

Output Format

One line with one integer, representing the final pleasure value.

Explanation/Hint

For $50\%$ of the testdata, $1 \leqslant A \leqslant B \leqslant 5\times10^3$. For $70\%$ of the testdata, $1 \leqslant A \leqslant B \leqslant 5\times10^4$. For $100\%$ of the testdata, $1 \leqslant A \leqslant B \leqslant 2\times10^7$. Translated by ChatGPT 5