March Break Contest '22 Problem 4 - Good Numbers

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

After participating in this year's Canadian Computing Competition, Bob has been enlightened with the knowledge that only certain numbers are good.

Let the digits of a number be of the form a_1a_2a_3...a_N, where a_1 > 0. Then, Bob says that the number is good if, for all i < N, a_i < a_{i + 1} if i is odd and a_i > a_{i + 1} if i is even.

Bob wants to find as many good numbers as possible. He would like you to help him find the number of good numbers in the range [L, R].

Input Specification

The first line will contain two space-separated integers, L and R (1 \le L \le R \le 10^{18}).

Subtask 1 [10%]

1 \le L \le R \le 10^{6}

Subtask 2 [90%]

No further constraints.

Output Specification

Output one integer containing the number of good numbers in the range.

Sample Input

20 30

Sample Output

7

Explanation for Sample Output

The numbers that are not good are 20, 21, 22, and 30.


Comments

There are no comments at the moment.