## An integer $s$ is called a superinteger of another integer $n$ if the digits of $n$ form a subsequenceA subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. of the digits of $s$.

For example, $2718281828$ is a superinteger of $18828$, while $314159$ is not a superinteger of $151$.

Let $p(n)$ be the $n$th prime number, and let $c(n)$ be the $n$th composite number. For example, $p(1) = 2$, $p(10) = 29$, $c(1)$ = 4 and $c(10) = 18$.

$\{p(i) : i \ge 1\} = \{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, \dots\}$

$\{c(i) : i \ge 1\} = \{4, 6, 8, 9, 10, 12, 14, 15, 16, 18, \dots\}$

Let $P^D$ be the sequence of the digital roots of $\{p(i)\}$ ($C^D$ is defined similarly for $\{c(i)\}$):

$P^D = \{2, 3, 5, 7, 2, 4, 8, 1, 5, 2, \dots\}$

$C^D = \{4, 6, 8, 9, 1, 3, 5, 6, 7, 9, \dots\}$

Let $P_n$ be the integer formed by concatenating the first $n$ elements of $P^D$ ($C_n$ is defined similarly for $C^D$).

$P_{10} = 2357248152$

$C_{10} = 4689135679$

Let $f(n)$ be the smallest positive integer that is a common superinteger of $P_n$ and $C_n$. For example, $f(10) = 2357246891352679$, and $f(100) \bmod 1\,000\,000\,007 = 771661825$.

Find $f(10\,000) \bmod 1\,000\,000\,007$.

### To solve this problem, we can use the concept of dynamic programming. We will create a function that calculates the maximum score for Player 1, given a sequence of numbers.

Let’s define a function `max_score(nums)` that takes a list of numbers and returns the maximum score for Player 1. Here’s the Python code:

“`python

def max_score(nums):

n = len(nums)

dp = [[0] * n for _ in range(n)] # dp[i][j] represents the maximum score between indices i and j

for i in range(n-1, -1, -1):

for j in range(i, n):

if i == j:

dp[i][j] = nums[i]

else:

dp[i][j] = max(nums[i] – dp[i+1][j], nums[j] – dp[i][j-1])

return dp[0][n-1]

“`

Now, let’s use this function to calculate `F(10^8)`.

“`python

MOD = int(1e9) + 7

s = [0] # sequence s starts with 0

for i in range(1, int(1e8)+1):

s.append((s[-1]**2 + 45) % MOD)

result = max_score(s)

print(result)

“`

This code will output the maximum score for Player 1, `F(10^8)`. Note that the computational complexity of this solution is O(N^2), where N is the length of the sequence s. Therefore, it might take some time to execute for large values of N.

##### More Answers:

A Weird Recurrence RelationMöbius Function and Intervals

Distinct Terms in a Multiplication Table