Matrix power
InterviewTime limit1sMemory limit256 MB
Compute the N by N matrix A raised to power B, with each entry reduced modulo 1000.
- Level
Easy3 of 10
- Topics
- Matrix, Divide and conquer
- Solved
- No attempts yet
Problem
You are given an matrix and an exponent . Write a program that computes .
The entries can grow very large, so print each entry of modulo 1,000.
Input
The first line contains the matrix size and the exponent , separated by a space. (, )
Each of the next lines contains one row of . Every entry is 0 or a positive integer not greater than 1,000.
Output
Print on lines. Line holds the entries of row separated by single spaces, each reduced modulo 1,000.