Hotel Room Numbers
InterviewTime limit1sMemory limit128 MB
For each pair N and M, count the integers in [N, M] whose decimal digits are all distinct, reading cases until end of file.
- Level
Easy3 of 10
- Topics
- Brute force, Math, Implementation
- Solved
- No attempts yet
Problem
Sunyoung believes that if a room number contains the same digit two or more times, misfortune will befall whoever stays in that room. So she will never use a number in which a digit repeats, such as 838 or 1004.
In 2050, Sunyoung has become the wealthiest person in Korea, and she plans to build a new hotel by the sea. To keep misfortune away from her guests, every room number must have no repeated digit.
The government granted the construction permit on the condition that each room number is at least and at most . Two different rooms cannot share the same number. What is the largest number of rooms the hotel can have? In other words, count the integers between and (inclusive) that contain no repeated digit.
Input
The input consists of several test cases. Each test case is given on one line as two integers and separated by a space. () The input continues until the end of file.
Output
For each test case, print on its own line the number of integers between and (inclusive) whose digits are all distinct (no digit repeats).