Sequences everywhere
Practice
4 (19 votes)
Mathematics
Hard
Problem
65% Success 595 Attempts 50 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Let's consider some integer X. We will call the following sequence S a sequence generated by X:

  1. for i = 1: S[i] = X
  2. for i > 1: S[i] equals to the minimal positive integer such that S[i] is not a divisor of S[i - 1]. If there is no such integer than S[i - 1] is the last element of S.

For example S = (10, 3, 2) is a sequence generated by 10.

Can you find the total sum of lengths of the sequnces generated by all the integers from A to B inclusive.

Input
The only line contains two integers: A and B. (A <= B)

Output
Output the only integer - answer to the question. It's guaranteed that this value can be stored in 64-bit integer.

Constraints
1 < A <= B <= 1017

Subtasks

  • B - A <= 106 in 30% of test data.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
393 votes
Tags:
Ad-HocApprovedEasyOpenSorting
Points:10
3 votes
Tags:
Very-Easy
Points:30
6 votes
Tags:
Basic ProgrammingBasics of Implementation