Submeter | Todas submissőes | Melhores | Voltar |
Problem hidden
MPOW - Power of matrix |
You will be given a square matrix M and a positive integer power N. You will have to compute M raised to the power N. (that is, M multiplied with itself N times.)
Input
First line of input is T (number of test-cases) First line of each test-case contains two integer M and N, where M is size of square matrix that we have to exponent and N is the power to which we have to exponent it. The next M lines describe the input matrix. Each line contains exactly M elements corresponding to each array
Output
Output M line corresponding to each row of resultant matrix Each line must have M integers where jth element of ith line is jth element of resultant matrix taken modulo with 1000000007 (109+7).
Simply, you have to print the resultant square matrix.
Example
Input: 2 2 3 1 0 1 1 3 3 1 0 4 1 2 2 0 4 4 Output: 1 0 3 1 17 112 116 15 88 100 28 144 160
Constraints
1 ≤ T ≤ 10
1 ≤ M ≤ 50
1 ≤ N ≤ 100000
0 ≤ each element of input matrix ≤ 109
Adicionado por: | ivar.raknahs |
Data: | 2014-12-19 |
Tempo limite: | 1s |
Tamanho do fonte: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Linguagem permitida: | Todas exceto: ASM64 CLOJURE ERL FSHARP PERL6 PY_NBC SCALA TCL |
Origem: | own |