Counting Divisible Products
Practice
5 (2 votes)
Algorithms
Dynamic programming
Problem
53% Success 457 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Sumit, a bright student with a passion for problem-solving, recently encountered a challenging question.

The task was to count the numbers within a range, specifically between \(L\) and \(R\), where the product of their individual digits is divisible by a positive integer \(P\).

Sumit loves challenges and turned to you, his helpful roommate, for assistance. Can you assist Sumit in solving this problem and showcase his impressive problem-solving skills?

Input Format:

The first line contains an integer \(T\), representing the number of test cases.

Each of the following \(T\) lines contains three integers: \(L\), \(R\), and \(P\).

Output Format:

For each test case, print the number of integers that meet the condition in a separate line.

Constraints:

\(1 \leq T \leq 10 \\ 1 \leq L \leq R \leq 10^9 \\ 1 \leq P \leq 10^9\)

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
14 votes
Tags:
Dynamic ProgrammingHardAlgorithmsMathematicsOpenApproved
Points:50
Tags:
Hard
Points:50
Tags:
Dynamic ProgrammingAlgorithms