#P7788. [COCI 2016/2017 #6] Savrsen

[COCI 2016/2017 #6] Savrsen

Description

A number is perfect if and only if it is equal to the sum of all its divisors that are smaller than it.

For example, 28=1+2+4+7+1428 = 1 + 2 + 4 + 7 + 14, so 2828 is perfect.

Based on this, we define the imperfection value F(N)F(N) of a number, which is the absolute value of the difference between NN and the sum of all divisors of NN that are smaller than NN.

For example, F(6)=6123=0F(6)=|6-1-2-3|=0.

F(11)=111=10F(11)=|11-1|=10.

F(24)=2412346812=12=12F(24)=|24-1-2-3-4-6-8-12|=|-12|=12.

Now you are given two positive integers AA and BB. Please compute F(A)+F(A+1)+...+F(B)F(A)+F(A+1)+...+F(B).

Input Format

One line with two integers AA and BB, as described above.

Output Format

One line with one integer, representing F(A)+F(A+1)+...+F(B)F(A)+F(A+1)+...+F(B).

1 9
21
24 24
12

Hint

Sample Explanation #1

F(1)+...+F(9)=1+1+2+1+4+0+6+1+5=21F(1)+...+F(9)=1+1+2+1+4+0+6+1+5=21.

Constraints

For 100%100\% of the testdata, 1A,B1071 \le A,B \le 10^7.

Notes

The score of this problem follows the original COCI settings, with a full score of 120120.

Translated from COCI2016_2017 CONTEST #6 T4 SAVRSEN.

Translated by ChatGPT 5