407187: GYM102697 158 Dot Product

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

158. Dot Producttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

For this problem, you will be tasked with finding the dot product of two given matrices. Dot products are a very common matrix operation, and find uses in many fields of math, computer science, and physics. If you haven't had any experience with a matrix in the past, think of matrices as a "table" of values, similar to a multi-dimensional array. Matrices can be of any dimension, yet this problem will only focus on two dimensional matrices. The result of a dot product operation on two matrices m1 and m2 in the form m1*m2 will result in a matrix with the same number of rows as m1, and the same number of columns as m2. It is difficult to explain the computation of the dot product in text, so here is an image representing it:

While there are many other aspects and components of the dot product operation, this is a simple and usable form of it. Your program should take two matrices m1 and m2, then compute the dot product of these as m3.Input

The first line contains four space separated integers, representing the width of m1, the height of m1, the width of m2, and the height of m2 respectively. The next lines will contain each row of m1 followed by each row of m2. Each row will include space separated integers that correspond to the values in that row of the matrix.

Output

A single matrix that represents the result of computing the dot product of m1 and m2.

ExampleInput
2 2 2 2
1 2
3 4
5 6
7 8
Output
19 22 
43 50 

加入题单

上一题 下一题 算法标签: