Mancunian And Naughty Numbers
Practice
3.3 (44 votes)
Mathematics
Easy
Number theory
Factorization
Problem
78% Success 3628 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Mancunian, our favourite football fan, is a die-hard supporter of Manchester United Football Club. Being so, he is desperate to attend the grand unveiling of Jose Mourinho as the next manager of the club. But, his arch-nemesis Liverbird (who is a Liverpool fan) wants him to fail. Knowing that Mancunian is weak at mathematics, he has given him a problem to solve before the ceremony. Can you help Mancunian do it and thwart the evil plans of Liverbird?

A \(naughty \ number\) is one whose number of distinct prime factors is equal to the number of digits in its decimal representation. The number 1 is considered a naughty number.

Given Q queries, each query specifying two integers a and b, find the number of \(naughty \ numbers\) lying between a and b (both included).

Input format

The first line contains an integer Q denoting the number of queries.
Each of the next Q lines consists of two integers a and b denoting the range for this query.

Output format

Print Q lines. The \(ith\) line contains the answer for the \(ith\) query.

Constraints

  • \(1 \le Q \le 50,000\)
  • \(1 \le a \le b \le 100,000\)

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:20
132 votes
Tags:
Number TheoryEasyMathematicsOpenApprovedFactorization
Points:20
13 votes
Tags:
Prime FactorizationEasyMathematicsFactorization
Points:20
6 votes
Tags:
Easy