luogu#P11173. 「CMOI R1」We Want To Run / Nilpotent
「CMOI R1」We Want To Run / Nilpotent
Background
$\small\color{white}54^{\text{th}}\text{Problem by ArCu}.$
Problem Description
For an matrix , define as the smallest positive integer such that . If no such integer exists, then . Here is the zero matrix, i.e. the matrix whose all entries are .
Given , there are different matrices whose every entry is an integer in . Compute the sum of over all these possible matrices .
Output the answer modulo .
Input Format
One line with two integers .
Output Format
One line with one integer, representing the answer you computed.
2 2
5
3 4
793
5 10
59350891
18 15932416
52138206
1 1
1
Hint
Note that for any positive integer , , so $f\left(\begin{bmatrix}1&0\\1&1\end{bmatrix}\right)=0$. Also, , so $f\left(\begin{bmatrix}0&0\\1&0\end{bmatrix}\right)=2$.
There are possible matrices in total. The only ones with are
$$f\left(\begin{bmatrix}0&0\\0&0\end{bmatrix}\right)=1,f\left(\begin{bmatrix}0&0\\1&0\end{bmatrix}\right)=f\left(\begin{bmatrix}0&1\\0&0\end{bmatrix}\right)=2$$So the answer is .
All testdata satisfy .
Translated by ChatGPT 5