P874
projecteuler.net

Maximal Prime Score

ℹ️Published on Sunday, 28th January 2024, 04:00 am; Solved by 538;
Difficulty rating: 15%

Let $p(t)$ denote the $(t+1)$th prime number. So that $p(0) = 2$, $p(1) = 3$, etc.
We define the prime score of a list of nonnegative integers $[a_1, \dots, a_n]$ as the sum $\sum_{i = 1}^n p(a_i)$.
Let $M(k, n)$ be the maximal prime score among all lists $[a_1, \dots, a_n]$ such that:

  • $0 \leq a_i < k$ for each $i$;
  • the sum $\sum_{i = 1}^n a_i$ is a multiple of $k$.

For example, $M(2, 5) = 14$ as $[0, 1, 1, 1, 1]$ attains a maximal prime score of $14$.

Find $M(7000, p(7000))$.



Soluzione

Last modified: May 01, 2025. Website built with Franklin.jl and the lovely Julia programming language.