Mancunian and Pandigital Numbers
Practice
3.7 (11 votes)
Approved
Easy
Math
Number theory
Number theory
Problem
81% Success 4806 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Mancunian is a fan of the special properties of numbers and adores all things numerical.

His latest fascination are the so-called "zeroless" Pandigital Numbers. But he has imposed an additional restriction that each digit (from 1-9) should occur atmost once in the number. Such zeroless pandigital numbers are called almighty pandigital numbers. To sum up, an almighty pandigital number is an integer (let its number of digits be d) such that it contains the digits from 1 to d exactly once. For example, 102 is a pandigital number but not zeroless. 231445 is a zeroless pandigital number but not almighty. 35124 is an almighty pandigital number.
Given Q queries, each of the type L R, he asks you to find the number of almighty pandigital numbers in the range from L to R (inclusive).

Input:
The first line contains Q denoting the number of queries. Each of the next Q lines is of the form L R denoting a specific query.

Output:
For each query, output the answer to the given query in a new line.

Constraints:
1 <= Q <= 105
1 <= L, R <= 106

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:30
52 votes
Tags:
Basic ProgrammingNumber theoryBasic Number Theory-1MathNumber Theory
Points:30
64 votes
Tags:
CombinatoricsEasyMathNumber theory
Points:30
53 votes
Tags:
EasyMath