Prime Qualification
Time limit2sMemory limit128 MB
Count primes between A and B whose decimal representation contains the digit D.
- Level
Easy3 of 10
- Topics
- Number theory, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
Farmer John is numbering his cows one by one with prime numbers. Bessie became curious about how often the digit shows up among these numbers.
Help Bessie count how many prime numbers in the range from to (inclusive) contain the digit in their decimal representation.
A prime is a natural number greater than 1 whose only divisors are 1 and itself. The first few primes are .
Input
Three integers , , and are given on one line, separated by spaces. Here is a single decimal digit (from to ).
Output
Print, on one line, the number of primes within the given range that contain the digit .
Constraints
Hint
For example, the primes in the range from to are and , and only contains the digit .