
2767. Qualified Primes
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 594 Accepted Runs: 114 Multiple test files
Farmer John has begun branding the cows with sequential prime
numbers. Bessie has noticed this and is curious about the occurrence
of various digits in those brands.
Help Bessie determine the number of primes in the inclusive range
A..B (1 ≤ A ≤ B ≤ 4,000,000; B ≤ A + 1,000,000; one test case
has B ≤ A + 2,000,000 ) that contain a supplied digit D.
A prime is a positive integer with exactly two divisors (1 and
itself). The first primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, and,
29.
Input
* Line 1: Three space-separated integers: A, B, and D
Output
* Line 1: The count of primes in the range that contain the digit D.
Sample Input
10 15 3
Sample Output
1
Input Details
How many primes in the range 10..15 contain the digit 3?
Output Details
Just 13 in this range contains a '3'.
Source: USACO January 07 Bronze
Submit List
Runs Forum Statistics
Tianjin University Online Judge v1.2.4