FarFromPrimes
SRM 291 · 2006-02-21 · by Andrew_Lazarev
Problem Statement
A prime number is an integer greater than 1 that has no positive divisors other than 1 and itself. The first prime numbers are 2, 3, 5, 7, 11, 13, 17, ...
The number N is considered far from primes if there are no prime numbers between N-10 and N+10, inclusive, i.e., all numbers N-10, N-9, ..., N-1, N, N+1, ..., N+9, N+10 are not prime.
You are given an
Constraints
- A will be between 10 and 100000, inclusive.
- B will be between A and 100000, inclusive.
- (B - A) will be between 0 and 1000, inclusive.
3328 4100 Returns: 4
The far from primes numbers are 3480, 3750, 3978 and 4038.
10 1000 Returns: 0
19240 19710 Returns: 53
23659 24065 Returns: 20
97001 97691 Returns: 89
Submissions are judged against all 103 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FarFromPrimes with a public method int count(int A, int B) · 103 test cases · 2 s / 256 MB per case