Diophantine
TCO19 Wildcard Fun Round · 2019-08-16 · by misof
Problem Statement
This problem has a nonstandard time limit: 7 seconds.
Let p[] be the sequence of all primes in increasing order: p[0]=2, p[1]=3, p[2]=5, and so on.
Let D be a positive integer constant. For each i >= 0, let q[i] = p[i] * p[i+D].
Consider the following equation: V + W + X + Y = Z.
You are given
Notes
- A positive integer is a prime if it has exactly two positive integer divisors. Note that 1 is not a prime.
Constraints
- N will be between 1 and 2,500, inclusive.
- D will be between 0 and 2,500, inclusive.
15 1 Returns: 2
The two solutions are: 6 + 15 + 323 + 323 = 667 6 + 143 + 221 + 1147 = 1517 Note that the first solution uses the value 323 twice.
2470 0 Returns: 0
No solutions at all.
30 500 Returns: 1
One solution. In it, the right-hand side of the equation is 406,279.
47 7 Returns: 14
1 0 Returns: 0
Submissions are judged against all 87 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Diophantine with a public method long long countSolutions(int N, int D) · 87 test cases · 2 s / 256 MB per case