COCI '12 Contest 1 #5 Snaga

View as PDF

Submit solution


Points: 12 (partial)
Time limit: 1.0s
Memory limit: 32M

Problem types

Let us begin with a positive integer N and find the smallest positive integer which doesn't divide N. If we repeat the procedure with the resulting number, then again with the new result and so on, we will eventually obtain the number 2. Let us define \text{strength}(N) as the length of the resulting sequence.

For example, for N = 6 we obtain the sequence 6, 4, 3, 2 which consists of 4 numbers, thus \text{strength}(6) = 4.

Given two positive integers A < B, calculate the sum of strengths of all integers between A and B (inclusive), that is,

\displaystyle \text{strength}(A) + \text{strength}(A + 1) + \dots + \text{strength}(B)

Input Specification

The first and only line of input contains two positive integers, A and B (3 \leq A < B < 10^{17}).

Output Specification

The first and only line of output should contain the requested sum of strengths.

Sample Input 1

3 6

Sample Output 1

11

Sample Input 2

100 200

Sample Output 2

262

Comments

There are no comments at the moment.