Aaryan and the Magical Numbers
Practice
4.5 (4 votes)
Mathematics
Dynamic programming
Open
Approved
Hard
Problem
14% Success 2814 Attempts 50 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Little Aaryan loves going to the magic shows, One fine day after attending a magic show, he thought randomly of some numbers, He introduced some magic in them, The magic was each number had atleast one prime digit in it. He called those numbers as magical numbers. Too excited next day, he went to the magic show and asked the performer to answer his following query

Given a number N, you have to find the number of magical numbers less than or equal to N.

Input:

First line will consist of value of T i.e testcases. Next T lines will have a number N.

Output:

Output the required value as answer.

Constraints:

T <= 10^6

N <= 10^18

Sample Input:

2

100

120

Sample Output:

64

73

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:50
2 votes
Tags:
AlgorithmsCounting and ArrangementsDynamic ProgrammingMath
Points:50
1 votes
Tags:
Basic ProgrammingDynamic ProgrammingCombinatoricsMathCounting and ArrangementsAlgorithms
Points:50
Tags:
Dynamic ProgrammingCombinatoricsGrammar-VerifiedHardRecruitProbability and StatisticsHiringBitmaskAlgorithmsBit manipulationMathematicsCounting and ArrangementsApproved