#P4863. JerryC's Joyful Drive
JerryC's Joyful Drive
JerryC's Joyful Drive
JerryC has purchased a sports car (although she does not have a driving license) and she drives it in a rather unconventional way! She decides to drive a sequence of road segments. In the simplified version of the problem, you are given two integers A and B. For each integer i in the range \( A \le i \le B \), she drives a segment that lasts for i seconds. In the j-th second of the segment, she gains a joy value given by:
[ \left\lfloor \frac{i}{j} \right\rfloor \times (-1)^j ]
Your task is to compute the total joy accumulated over all segments, i.e., compute the following sum:
[ \sum_{i=A}^{B}; \sum_{j=1}^{i} \left\lfloor \frac{i}{j} \right\rfloor \times (-1)^j ]
Note: In this problem, \( (-1)^j \) alternates the sign of the contributions from each second, as JerryC happens to dislike odd seconds.
inputFormat
The input consists of a single line containing two integers A and B (with A ≤ B), separated by a space.
outputFormat
Output a single integer, the total joy value computed by the above formula.
sample
1 1
-1