Playing with digits
Practice
4.1 (36 votes)
Digit dp
Dynamic programming
Algorithms
Advanced
Math
Problem
90% Success 9039 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Determine the number of integers that are available from \(A\) to \(B\) (inclusive) and satisfy the following conditions:

  • Sum of its digits is equal to a prime number
  • Divisible by \(k\)

Input format

The first and only line contains three space-separated positive integers \(A\), \(B\), and \(K\).

Output format

Print a single integer that denotes the answer to this question.

Constraints

\(0 < A,\ B,\ K ≤ 2*(10^{10})\\ A ≤ B\)

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
Tags:
Medium
Points:20
290 votes
Tags:
MathematicsOpenApprovedEasyProbability and Statistics
Points:10
330 votes
Tags:
ApprovedEasyImplementationReady