In this problem, you are asked to implement a class Matrix
that represents a $N\times N$ Matrix.
Following are the methods you should implement:
A.add(B)
→ $A = A+B$A.subtract(B)
→ $A = A-B$A.multiply(B)
→ $A = AB$A.transpose()
→ $A = A^{\top}$A.power(x)
→ $\underbrace{AA \dots AA}_{\times x}$Power of matrix:
Reference
The first line contains two integers $N$, $T$, representing the size of the matrix and the number of the operations.
Following are $N$ lines, each line contains $N$ integers, representing the element in the starting matrix.
Following are $T$ operations, each operation start with an interger $o$, representings the type of the operation.
For operation type 1, 2, 3, interger $o$ is followed by $N\times N$ numbers, representing the element in the operand matrix.
For operation type 5, interger $o$ is followed by an interger $x$, repersentings $x$-th power.
Constraints
long long
.Subtask
Output the final result of the matrix.