Playing with digits
Tag(s):

## Advanced, Algorithms, Digit DP, Dynamic Programming, Math

Problem
Editorial
Analytics

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$

SAMPLE INPUT
5 86 4
SAMPLE OUTPUT
7
Explanation

There are 7 such numbers: 12 16 20 32 52 56 76

Time Limit: 1,0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in Challenge Name

October Easy' 19

OTHER PROBLEMS OF THIS CHALLENGE
• Math > Number Theory
• Math > Basic Math
• Algorithms > Graphs
• Math > Basic Math
Уведомления

?