GFSSOC '17 S2 - Ace is Base

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 0.6s
Memory limit: 64M

Authors:
Problem type

Ace is bored on a car ride to Waterloo. He loves numbers and he has invented a new number system to prove to Waterloo that he is passionate about math. Ace has classified an Ace number as a number whose hexadecimal representation consists only of A, C, or E. For example, 10, 202, and 2766 are Ace numbers because their hex representations are A, CA, and ACE respectively. Ace would like to know how many Ace numbers there are between a closed interval [a,b].

Input Specification

First line: a.
Second line: b.

For 40\% of the marks, 1 \le a \le b \le 10^6.
For an additional 60\% of the marks, 1 \le a \le b \le 10^{10}.

Sample Input 1

1
100

Sample Output 1

3

Explanation

The three Ace numbers are 10, 12, and 14.


Comments


  • -1
    alexelliott  commented on Feb. 9, 2020, 9:25 p.m. edited

    I am assuming that it is including a and b, right?


    • 1
      omar1o1  commented on July 14, 2021, 3:00 p.m. edited

      Closed interval, so yeah