But one day, you will stand before its decrepit gate,without really knowing why.
0%
Matrix Power Series
Posted onIn算法
,
POJ
,
数组 Symbols count in article: 2.2kReading time ≈2 mins.
来源POJ第3233题Matrix Power Series
Description
Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak.
Input
The input contains exactly one test case. The first line of input contains three positive integers n (n ≤ 30), k (k ≤ 109) and m (m < 104). Then follow n lines each containing n nonnegative integers below 32,768, giving A’s elements in row-major order.
Output
Output the elements of S modulo m in the same way as A is given.