modified matrix multiplication, add a solution of less time complexity