Alice enlists the help of some friends to generate a random number, using a single unfair coin. She and her friends sit around a table and, starting with Alice, they take it in turns to toss the coin. Everyone keeps a count of how many heads they obtain individually. The process ends as soon as Alice obtains a Head. At this point, Alice multiplies all her friends’ Head counts together to obtain her random number.
As an illustration, suppose Alice is assisted by Bob, Charlie, and Dawn, who are seated round the table in that order, and that they obtain the sequence of Head/Tail outcomes THHH—TTTT—THHT—H beginning and ending with Alice. Then Bob and Charlie each obtain 2 heads, and Dawn obtains 1 head. Alice’s random number is therefore $2\times 2\times 1 = 4$.
Define $e(n, p)$ to be the expected value of Alice’s random number, where $n$ is the number of friends helping (excluding Alice herself), and $p$ is the probability of the coin coming up Tails.
It turns out that, for any fixed $n$, $e(n, p)$ is always a polynomial in $p$. For example, $e(3, p) = p^3 + 4p^2 + p$.
Define $c(n, k)$ to be the coefficient of $p^k$ in the polynomial $e(n, p)$. So $c(3, 1) = 1$, $c(3, 2) = 4$, and $c(3, 3) = 1$.
You are given that $c(100, 40) \equiv 986699437 \text{ } (\text{mod } 10^9+7)$.
Find $c(10000000, 4000000) \mod 10^9+7$.
This problem appears to be number 731 of Project Euler, so it is not intended to be solvable through manual calculation or using elementary math. It requires strong understanding of advanced probability and combinatorics, plus some clever observations to simplify the problem, and a bit of programming to compute the final result.
To solve this problem, we first need to generate the generation function F(n, p) = SUM[k=0, n](c(n, k) * p^k). Then we can work out F(n, p) recursively. From the turn-taking process, we can see that F(0,p) = 1, and for n > 0, F(n, p) = p * (1+F(n-1, p))+p*F(n-1,p) = p + 2p * F(n-1, p).
When obtaining F(n, p), c(n, k) equals the coefficient of p^k in F(n, p): c(n, k) = the coefficient of p^k in (p + 2p * F(n-1, p)), which can be calculated recursively as c(n, k) = (c(n-1, k-1) + 2*c(n-1, k-1)) mod (10^9+7), because we only care about the remainder when divided by (10^9+7).
To find c(10000000, 4000000) mod (10^9+7), you will need to implement the recursive formulas in an efficient way to prevent exceeding the machine limits for big numbers or running out of time. Iterative algorithms with memoization or dynamic programming will be helpful. The problem itself is a typical combination of mathematics and computational problem-solving skills, typical for Project Euler problems.
More Answers:
Distinct Colourings of a Rubik’s CubeInteger Sided Equiangular Hexagons
Divisibility Streaks