# Virus Sniper: Solution ## Comparing solutions The linear expectation transition matrix in the problem setter’s solution models the spread. When exponentiating it, the step count must not simply be reduced modulo $P-1$ : Fermat’s theorem for nonzero field elements does not extend to arbitrary matrices. For example, over the field modulo prime $P$ , let $H=\begin{pmatrix}1&1\\0&1\end{pmatrix}$ . Then $H^t=\begin{pmatrix}1&t\\0&1\end{pmatrix}$ . At $t=P-1$ this is not the identity, whereas reducing the exponent first gives zero. Such a matrix also represents retaining existing counts while adding them to a following level. The full exponent must therefore be handled correctly. A direct way to evaluate the matrix model is binary exponentiation using the entire big-integer exponent. For $b$ bits and dimension $d$ , each exponent takes $O(bd^3)$ field operations and $O(d^2+b)$ space. The implementation used by Codex (GPT-6) reduces powers by the characteristic polynomial, making the polynomial stage $O(d^2)$ per bit, with additional preprocessing and matrix reconstruction. Full bounds follow below. It handles the complete exponent correctly and reduces repeated matrix multiplication, at the cost of polynomial preprocessing and a more involved implementation. ## Initial values and expectation transitions Apply the $Q$ rectangle additions with a two-dimensional difference array, then take two-dimensional prefix sums to recover the initial field. Raw intensities are at most $10^{15}$ ; use 64-bit integers for accumulation. All following algebra takes place modulo the prime $P=1000000009$ . Since $1\le b