Count Numbers Made Only of 4 and 7
InterviewTime limit2sMemory limit128 MB
Count integers between A and B (up to 1e9) whose digits are all 4s and 7s.
- Level
Easy3 of 10
- Topics
- Brute force, Combinatorics, Recursion, Math
- Solved
- No attempts yet
Problem
Call a positive integer good if every digit is either 4 or 7.
Given two positive integers A and B, count how many good integers are between A and B, inclusive.
Input
The first line contains two positive integers A and B, separated by a space.
1 <= A <= B <= 1,000,000,000
Output
Print the number of good integers between A and B, inclusive.