Search Problems   RSS Feed
projecteuler.net

March of the Penguins

 Published on Saturday, 19th September 2026, 08:00 pm and solved by 17

Problem 1010

$m$ penguins start on the real number line at positions $1,\dots,m$, all facing in the positive direction. At each step, a single penguin marches forward $1$ unit. However, as no two penguins can occupy the same position, a penguin is only able to move if the space ahead of it is currently free.

For example, for $m=2$ penguins there are six ways their march can proceed over four steps: $$\begin{align} &(1,2)\rightarrow(1,3)\rightarrow(1,4)\rightarrow(1,5)\rightarrow(1,6)\\ &(1,2)\rightarrow(1,3)\rightarrow(1,4)\rightarrow(1,5)\rightarrow(2,5)\\ &(1,2)\rightarrow(1,3)\rightarrow(1,4)\rightarrow(2,4)\rightarrow(2,5)\\ &(1,2)\rightarrow(1,3)\rightarrow(1,4)\rightarrow(2,4)\rightarrow(3,4)\\ &(1,2)\rightarrow(1,3)\rightarrow(2,3)\rightarrow(2,4)\rightarrow(2,5)\\ &(1,2)\rightarrow(1,3)\rightarrow(2,3)\rightarrow(2,4)\rightarrow(3,4) \end{align} $$

We see there is one way the march ends with final position vector $(1,6)$; three ways it ends at $(2,5)$; and two ways it ends at $(3,4)$.

Given the number of penguins $m$ and the total number of steps $n$, define $f(v)$ to be the number of ways the march ends with the final position vector $v$. From the example above, with $m=2$ and $n=4$: $$\begin{align} f((1,6))&=1\\ f((2,5))&=3\\ f((3,4))&=2 \end{align} $$ Define $F(m, n)$ to be the product of $f(v)$ over all $v$ such that $f(v)$ is nonzero. For example $F(2,4)=1\times3\times2=6$.

You are also given $F(3,6)=180000$ and $F(5,10)\equiv 411456133\bmod{1234567891}$.

Find $F(150,300)$ giving your answer modulo $1234567891$.



Copied to Clipboard