#P7586. [COCI 2012/2013 #1] SNAGA

[COCI 2012/2013 #1] SNAGA

Description

Starting from a positive integer NN, find the smallest positive integer that is not divisible by NN. If we repeat this process using the obtained positive integer, we will eventually get 22.

Define strength(N)\operatorname{strength}(N) as the length of the resulting sequence. For example, for N=6N = 6, we can obtain the sequence 6,4,3,26,4,3,2, which consists of 44 numbers, so strength(6)=4\operatorname{strength}(6) = 4.

Given two positive integers A,BA, B, compute:

i=ABstrength(i)\sum\limits_{i=A}^B \operatorname{strength}(i)

Input Format

The input consists of one line containing two integers A,BA, B separated by a space.

Output Format

Output one integer on a single line, representing the result.

3 6
11
100 200
262

Hint

Constraints

For 100%100\% of the testdata, it is guaranteed that 3A<B10173 \le A < B \le 10^{17}.

Notes

The scoring for this problem follows the original COCI settings, with a full score of 140140.

Translated from COCI2012-2013 CONTEST #1 T5 SNAGA.

Translated by ChatGPT 5