#2401. Matrix Power Series

Matrix Power Series

Matrix Power Series

题目描述

Givena $n×n$ matrix $A$ and apositive integer $k$,find the sum $S=A+A^2 +A^3 +...+A^k$.

输入格式

The input contains exactly one test case. The first line of input contains three positive integers $n$ ($n \le 30$), $k$ ($k \le 10^9$) and $m$ ($m

输出格式

Output the elements of $S$ modulo $m$ in the same way as $A$ is given.
2 2 4 
0 1 
1 1
1 2
2 3

提示

(暂无提示) 标签: P10502|O2优化|矩阵加速

来源

P10502|Matrix Power Series