luogu#P7776. 【模板】特征多项式
【模板】特征多项式
Background
This is a template problem.
Problem Description
Given and an matrix , find its characteristic polynomial modulo .
Input Format
The first line contains a positive integer .
Next lines each contain non-negative integers, representing the matrix .
Output Format
Output one line with positive integers, representing the coefficients of its characteristic polynomial from low degree to high degree.
3
1 2 3
4 5 6
7 8 9
0 998244335 998244338 1
Hint
For an matrix , let its characteristic polynomial be , which satisfies
where is the identity matrix.
For of the testdata, .
For of the testdata, .
For another of the testdata, , i.e. is an upper triangular matrix.
For another of the testdata, , i.e. is an upper Hessenberg matrix.
For of the testdata, , .
Translated by ChatGPT 5