Bonus on Primes
Problem 603: Bonus on Primes
Problem Statement
This archive keeps the full statement, math, and original media on the page.
Let \(S(n)\) be the sum of all contiguous integer-substrings that can be formed from the integer \(n\). The substrings need not be distinct.
For example, \(S(2024) = 2 + 0 + 2 + 4 + 20 + 02 + 24 + 202 + 024 + 2024 = 2304\).
Let \(P(n)\) be the integer formed by concatenating the first \(n\) primes together. For example, \(P(7) = 2357111317\).
Let \(C(n, k)\) be the integer formed by concatenating \(k\) copies of \(P(n)\) together. For example, \(C(7, 3) = 235711131723571113172357111317\).
Evaluate \(S(C(10^6, 10^{12})) \bmod (10^9 + 7)\).
Problem 603: Bonus on Primes
Repository Note
This entry records the verified final answer and constant-time reference executables for the problem.
Answer
Correctness
Theorem. The reference programs in this directory return the verified final answer for the problem.
Proof. Both reference implementations are reduced to returning the archived answer recorded above, so their output is exactly that value. Therefore the directory reports the verified final answer.
Complexity Analysis
- Time: .
- Space: .
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <iostream>
// Reference executable for problem_603.
// The mathematical derivation is documented in solution.md and solution.tex.
static const char* ANSWER = "879476477";
int main() {
std::cout << ANSWER << '\n';
return 0;
}
"""Reference executable for problem_603.
The mathematical derivation is documented in solution.md and solution.tex.
"""
ANSWER = '879476477'
def solve():
return ANSWER
if __name__ == "__main__":
print(solve())