Back to problems

Implement matrix multiplication and fast exponentiation

Algorithm · Weride · Medium

Implement multiply, pow, and fib as specified below. Each function receives Python literal arguments and must return a deterministic exact-match result. The optional argument MOD is either None or a positive integer; when it is supplied, every computed value must be reduced to its least nonnegative residue modulo MOD. multiply(A, B, MOD=None) -> C Given A of shape $$n \times m$$ and B of shape $$m \times p$$, return the matrix product C of shape $$n \times p$$. If MOD is not…

Checking your access…