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

For the jj-th second of the ii-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,BA, 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,BA, B.

Output Format

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

1 1
-1
2 2
-1
3 3
-3

Hint

For 50%50\% of the testdata, 1AB5×1031 \leqslant A \leqslant B \leqslant 5\times10^3.
For 70%70\% of the testdata, 1AB5×1041 \leqslant A \leqslant B \leqslant 5\times10^4.
For 100%100\% of the testdata, 1AB2×1071 \leqslant A \leqslant B \leqslant 2\times10^7.

Translated by ChatGPT 5