luogu#P11173. 「CMOI R1」We Want To Run / Nilpotent

    ID: 10338 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划 DP数学2024洛谷原创O2优化动态规划优化图论建模线性代数

「CMOI R1」We Want To Run / Nilpotent

Background

$\small\color{white}54^{\text{th}}\text{Problem by ArCu}.$

Problem Description

For an n×nn \times n matrix AA, define f(A)f(A) as the smallest positive integer bb such that Ab=OA^b = O. If no such integer exists, then f(A)=0f(A)=0. Here OO is the zero matrix, i.e. the matrix whose all entries are 00.

Given n,an,a, there are an2a^{n^2} different n×nn \times n matrices whose every entry is an integer in [0,a)[0,a). Compute the sum of f(A)f(A) over all these an2a^{n^2} possible matrices AA.

Output the answer modulo 202407031202407031.

Input Format

One line with two integers n,a(1n600,0<a<264)n,a(1\leq n\leq 600,0<a<2^{64}).

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

Sample 1 Explanation:\text{Sample 1 Explanation}:

Note that for any positive integer bb, [1011]bO\begin{bmatrix}1&0\\1&1\end{bmatrix}^b\neq O, so $f\left(\begin{bmatrix}1&0\\1&1\end{bmatrix}\right)=0$. Also, [0010]2=O\begin{bmatrix}0&0\\1&0\end{bmatrix}^2=O, so $f\left(\begin{bmatrix}0&0\\1&0\end{bmatrix}\right)=2$.

There are 24=162^4=16 possible matrices in total. The only ones with f(A)0f(A)\neq 0 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 1+2+2=51+2+2=5.

Details of Subtasks:\text{Details of Subtasks}:

All testdata satisfy 1n600,0<a<2641\leq n\leq 600,0<a<2^{64}.

Subtask\text{Subtask} Special Constraints\text{Special Constraints} Score\text{Score}
11 n5,a2n\leq 5,a\leq 2 33
22 n5n\leq 5 77
33 n10n\leq 10 1010
44 n40n\leq 40 2020
55 n200n\leq 200 3030
66

Hint:202407031=13009×15559.\text{Hint}:202407031=13009\times 15559.

Translated by ChatGPT 5