Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Matrix Multiplication

Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula:

\[
c_{ij} = \sum_{k=1}^m a_{ik}b_{kj}
\]

  where $a_{ij}$, $b_{ij}$ and $c_{ij}$ are elements of $A$, $B$ and $C$ respectively.

Input

  In the first line, three integers $n$, $m$ and $l$ are given separated by space characters

  In the following lines, the $n \times m$ matrix $A$ and the $m \times l$ matrix $B$ are given.

Output

  Print elements of the $n \times l$ matrix $C$ ($c_{ij}$). Print a single space character between adjacent elements.

Constraints

$1 \leq n, m, l \leq 100$

$0 \leq a_{ij}, b_{ij} \leq 10000$

Sample Input

3 2 3
1 2
0 3
4 5
1 2 1
0 3 2

Sample Output

1 8 5
0 9 6
4 23 14

Note

      解説      

	



Sample input:
3 2 3
1 2
0 3
4 5
1 2 1
0 3 2


Sample output:
1 8 5
0 9 6
4 23 14

Submission status: Runtime Error

Solution code:
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
    
for li in range(l):
    print(" ".join([str(s) for s in C[li]]))

Submission status: Runtime Error

Solution code:
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([int(i) for i in input().split()])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
            
for li in range(l):
    print(" ".join([str(s) for s in C[li]]))

Submission status: Runtime Error

Solution code:
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []
for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for li in range(l):
    print(" ".join([str(s) for s in C[li]]))

Submission status: Runtime Error

Solution code:
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([int(i) for i in input().split()])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for ni in range(l):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Runtime Error

Solution code:

n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        c.append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for li in range(l):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Runtime Error

Solution code:

n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        c.append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for ni in range(n):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Runtime Error

Solution code:
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for ni in range(l):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Runtime Error

Solution code:
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for li in range(l):
    print(" ".join([str(s) for s in C[li]]))

Submission status: Runtime Error

Solution code:
n , m ,l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for mi in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for  li in range(l):
    print(" ",join([str(s) for s in C[ni]]))

Submission status: Runtime Error

Solution code:
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])    for  j in range(l):
        C.append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for ni in range(n):
    print(" ".join(str(s) for s in C[ni]))

Submission status: Runtime Error

Solution code:
n , m ,l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for mi in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for  ni in range(l):
    print(" ",join([str(s) for s in C[ni]]))

Submission status: Runtime Error

Solution code:
n, m, l, = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for li in range(n):
    print(" ".join([str(s) for s in C[li]]))

Submission status: Runtime Error

Solution code:
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])    
    for  j in range(l):
        C.append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for ni in range(n):
    print(" ".join(str(s) for s in C[ni]))

Submission status: Runtime Error

Solution code:
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for li in range(l):
    print(" ".join([str(s) for s in C[ni]))

Submission status: Runtime Error

Solution code:
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for ni in range(l):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Runtime Error

Solution code:
n, m ,l = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for j in range(m)]
c = [[0 for i in range(n)] for k in range(l)]

for i in range(n):
    for k in range(l):
        for j in range(m):
            c[i][k] += a[i][j] * b[j][k]

for i in range(n):
    print(" ".join(str(t) for t in c[i]))

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())
A = []
B = []
C = [[0] * l for i in range(n)]
for x in range(n):
	for y in range(m):
		A[x].append(list(map(int, input().split())))

for x in range(m):
	for y in range(l):
		B[x].append(list(map(int, input().split())))

for x in range(n):
	for y in range(l):
		sum = 0
		for z in range(m):
			sum += A[x][z] * B[z][y]
		C[x][y] = sum

for x in range(n):
	for y in range(l-1):
		print("{0} ".format(C[x][y], end = '')
	print(C[x][y+1])

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())
A = []
B = []
C = [[0] * l for i in range(n)]
for x in range(n):
	for y in range(m):
		A[x].append(list(map(int, input().split())))

for x in range(m):
	for y in range(l):
		B[x].append(list(map(int, input().split())))

for x in range(n):
	for y in range(l):
		sum = 0
		for z in range(m):
			sum += A[x][z] * B[z][y]
		C[x][y] = sum

for x in range(n):
	for y in range(l-1):
		print("{0} ".format(C[x][y], end = '')
	print(C[x][l-1])

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())
A = []
B = []
C = [[0] * l for i in range(n)]
for x in range(n):
	for y in range(m):
		A[x].append(list(map(int, input().split())))

for x in range(m):
	for y in range(l):
		B[x].append(list(map(int, input().split())))

for x in range(n):
	for y in range(l):
		sum = 0
		for z in range(m):
			sum += A[x][z] * B[z][y]
		C[x][y] = sum

for x in range(n):
	for y in range(l-1):
		print("{0} ".format(C[x][y]), end = '')
	print(C[x][l-1])

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())
A = []
B = []
C = [[0] * l for i in range(n)]
for x in range(n):
	A[x].append(list(map(int, input().split())))

for x in range(m):
	B[x].append(list(map(int, input().split())))

for x in range(n):
	for y in range(l):
		sum = 0
		for z in range(m):
			sum += A[x][z] * B[z][y]
		C[x][y] = sum

for x in range(n):
	for y in range(l-1):
		print("{0} ".format(C[x][y]), end = '')
	print(C[x][l-1])

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for i in range(m)]
C = [[0 for i in range(n)] for j in range(l)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k]*B[k][j]
for i in range(n):
    print(" ".join(map(str, C[i])))

Submission status: Runtime Error

Solution code:
n,m,l=list(map(int,input().split()))
A=[]
B=[]
for i in range(n):
	A.append(list(map(int,input().split())))
for i in range(m):
	B.append(list(map(int,input().split())))
import numpy as np 
A=np.array(A)
B=np.array(B)
A=A.dot(B)
for i in A:
	print(" ".join(list(map(str,i))))

Submission status: Runtime Error

Solution code:

n, m, l = map(int, input().split())

A = []
B = []

for i in range(n):
    A.append([int(j) for j in input().split()])

for i in range(m):
    B.append([int(j) for j in input().split()])

# ??????????????????????????????B?????¢??????????????¨???????????????
B_T = list(map(list, zip(*B)))

C = [[0 for i in range(n)] for j in range(l)]

for i in range(n):
    for j in range(l):
        C[i][j] = sum([a * b for (a, b) in zip(A[i], B_T[j])])

for i in range(n):
    print(*C[i])

Submission status: Runtime Error

Solution code:
n, m ,l = map(int, input().split())

A = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for j in range(m)]

C = [[0 for i in range(l)] for j in range(n)]

for i in range(l):
	for j in range(n):
		for k in range(m):
			C[i][j] + = (A[i][k] * B[k][j])

Cp = [print(" ".join(map(str, C[i]))) for i in range(n)]

Submission status: Runtime Error

Solution code:
n, m ,l = map(int, input().split())

A = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for j in range(m)]

C = [[0 for i in range(l)] for j in range(n)]

for i in range(l):
	for j in range(n):
		for k in range(m):
			C[i][j] += (A[i][k] * B[k][j])

Cp = [print(" ".join(map(str, C[i]))) for i in range(n)]

Submission status: Runtime Error

Solution code:
 import sys

def input_number():
    for i in range(n):
        adding=map(int,raw_input().split())
        A.append(adding)
    for i in range(m):
        adding=map(int,raw_input().split())
        B.append(adding)

if __name__ == '__main__':
    n,m,l=map(int,raw_input().split())
    A=[]
    B=[]
    ans=[[0 for i in range(n)]for j in range(l)]
    input_number()
    for i in range(n):
        for j in range(l):
            for k in range(m):
                ans[i][j] += A[i][k] * B[k][j]
    for i in range(n):
        for j in range(l):
            sys.stdout.write("%d" % ans[i][j])
            if j != l-1:
                sys.stdout.write(" ")
        sys.stdout.write("\n")

Submission status: Runtime Error

Solution code:
import sys

def input_number():
    for i in range(n):
        adding=map(int,raw_input().split())
        A.append(adding)
    for i in range(m):
        adding=map(int,raw_input().split())
        B.append(adding)

if __name__ == '__main__':
    n,m,l=map(int,raw_input().split())
    A=[]
    B=[]
    ans=[[0 for i in range(n)]for j in range(l)]
    input_number()
    for i in range(n):
        for j in range(l):
            for k in range(m):
                ans[i][j] += A[i][k] * B[k][j]
    for i in range(n):
        for j in range(l):
            sys.stdout.write("%d" % ans[i][j])
            if j != l-1:
                sys.stdout.write(" ")
        sys.stdout.write("\n")

Submission status: Runtime Error

Solution code:
import numpy as np

n, m, l=map(int, input().split(" "))

A = np.matrix([ [ int(a) for a in input().split() ] for i in range(n) ])
B = np.matrix([ [ int(b) for b in input().split() ] for i in range(m) ])
C = A.dot(B)


for i in range(l):
    out_C = ""
    for j in range(n):
        out_C = out_C + " " + str(C[i, j])
    
    print(out_C.strip())

Submission status: Runtime Error

Solution code:
from numpy import *

n, m, l=map(int, input().split(" "))

A = matrix([ [ int(a) for a in input().split() ] for i in range(n) ])
B = matrix([ [ int(b) for b in input().split() ] for i in range(m) ])
C = A.dot(B)


for i in range(l):
    out_C = ""
    for j in range(n):
        out_C = out_C + " " + str(C[i, j])
    
    print(out_C.strip())

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
 
import numpy
 
def func():
    try:
        (n,m,l) = [ int(item) for item in input().rstrip().split(" ") ]
        matrix_A = numpy.array([ [ int(item) for item in input().rstrip().split(" ") ] for i in range(n) ])
        matrix_B = numpy.array([ [ int(item) for item in input().rstrip().split(" ") ] for i in range(m) ])
    except:
        return inputError()
        
    matrix_C = numpy.dot(matrix_A, matrix_B)

    result=""
    for vector in matrix_C:
        for item in vector:
            result+=str(item)+" "
        result.rstrip()
        result+="\n"
    print(result.rstrip())

def inputError():
    '''
    print("input Error")
    return -1
    '''
 
    print("input Error")
    return -1
     
func()

Submission status: Runtime Error

Solution code:
def func(amat, bmat, nm):
    ans = [[0 for i in range(nm[0])] for j in range(nm[2])]
    for i in range(nm[0]):
        for j in range(nm[1]):
            for l in range(nm[2]):
                ans[i][l] += amat[i][j] * bmat[j][l]
    for i in ans:
        print("{0} {1} {2}".format(i[0], i[1], i[2]))


if __name__ == '__main__':
    nm = [int(i) for i in input().split(' ')]
    amat = [[0 for i in range(nm[1])] for j in range(nm[0])]
    bmat = [[0 for i in range(nm[2])] for i in range(nm[1])]

    for i in range(nm[0]):
        a = input().split(' ')
        for j in range(nm[1]):
            amat[i][j] = int(a[j])

    for i in range(nm[1]):
        b = input().split(' ')
        for j in range(nm[2]):
            bmat[i][j] = int(b[j])

    func(amat, bmat, nm)

Submission status: Runtime Error

Solution code:
def func(amat, bmat, nm):
    ans = [[0 for i in range(nm[0])] for j in range(nm[2])]
    for i in range(nm[0]):
        for j in range(nm[1]):
            for l in range(nm[2]):
                ans[i][l] += amat[i][j] * bmat[j][l]
    for i in ans:
        print(' '.join(map(str, i)))


if __name__ == '__main__':
    nm = [int(i) for i in input().split(' ')]
    amat = [[0 for i in range(nm[1])] for j in range(nm[0])]
    bmat = [[0 for i in range(nm[2])] for i in range(nm[1])]

    for i in range(nm[0]):
        a = input().split(' ')
        for j in range(nm[1]):
            amat[i][j] = int(a[j])

    for i in range(nm[1]):
        b = input().split(' ')
        for j in range(nm[2]):
            bmat[i][j] = int(b[j])

    func(amat, bmat, nm)

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split(' '))

A = []
for i in range(n):
    A.append(list(map(int, input().split(' '))))

B = []
for i in range(m):
    B.append(list(map(int, input().split(' '))))

C = [[0 for i in range(n)] for j in range(l)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for c in C:
    print(' '.join([str(x) for x in c]))

Submission status: Runtime Error

Solution code:
n,m,l = map(int,input().split())
a = [list(map(int,input().split() for _ in range(n)]
b = [list(map(int,input().split() for _ in range(m)]
c = [[sum(ak*bk for ak,bk in zip(ai,bj)) for ai in a] for bj in zip(*b)]
for ci in c:
    print(*c)

Submission status: Runtime Error

Solution code:
n,m,l = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
b = [list(map(int,input().split())) for _ in range(m)]
c = [[sum(ak*bk for ak,bk in zip(ai,bj) for bj in zip(*b)] for ai in a]
for ci in c:
    print(*c)

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())
a = [[int(num) for num in input().split()] for i in range(n)]
b = [[int(num) for num in input().split()] for i in range(m)]
c = [[0 for i in range(n)] for j in range(l)]
for i in range(l):
    for j in range(n):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]

for i in range(n):
    for j in range(l):
        if j == l - 1:
            print(c[i][j])
        else:
            print("{0} ".format(c[i][j]), end = "")

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())

A = []
B = []

for _ in range(n):
    A.append(list(map(int, input().split())))

for _ in range(m):
    B.append(list(map(int, input().split())))

C = [[sum([A[i][k] * B[k][j] for k in range(m)]) for j in range(n)] for i in range(l)]

for row in C:
    print(' '.join(map(str, row)))

Submission status: Runtime Error

Solution code:
n,m,l=[int(i) for i in input().split()]
x=[[int(0) for i in range(m)]for j in range(n)]
z=[[int(0) for i in range(l)]for j in range(n)]
y=[[int(0)for i in range(n)]for j in range(m)]
for i in range(n):
    k=input().split()
    for j in range(m):
        x[i][j]=int(k[j])
for i in  range(m):
    k=input().split()
    for j in range(n):
        y[i][j]=int(k[j])
        
for i in range(n):
    for j in range(l):
        count=int(0)
        for v in range(m):
            count=count+x[i][v]*y[v][j]
        z[i][j]=count
for i in range(n):
    for j in range(n-1):
        print(z[i][j],"",end="")
    print(z[i][n-1])

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())
A = [[int(n) for n in input().split()] for i in range(n)]
B = [[int(n) for n in input().split()] for i in range(m)]
C = [[0 for i in range(l)] for j in range(n)]
for i in range(l):
    for j in range(n):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for i in range(n):
    for j in range(l):
        if j == l - 1:
            print(C[i][j])
        else:
            print(C[i][j], end = " ")

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())
A = [[int(n) for n in input().split()] for i in range(n)]
B = [[int(n) for n in input().split()] for i in range(m)]
C = [[0 for i in range(l)] for i in range(n)]
for i in range(l):
    for j in range(n):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for i in range(n):
    for j in range(l):
        if j == l - 1:
            print(C[i][j])
        else:
            print(C[i][j], end = " ")

Submission status: Runtime Error

Solution code:
n,m,l=map(int,input().split())
for i in range(n):
    a+=[list(map(int,input().split()))]

for i in range(m):
    b+=[list(map(int,input().split()))]
    
c=[[a[i][k]*b[k][i] for i in range(n)] for k in range(l)]
print(c)

Submission status: Runtime Error

Solution code:
# Aizu Problem ITP_1_7_D: Matrix Multiplication
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def matrixmult (A, B):
    C = [[0 for row in range(len(A))] for col in range(len(B[0]))]
    for i in range(len(A)):
        for j in range(len(B[0])):
            for k in range(len(B)):
                C[i][j] += A[i][k]*B[k][j]
    return C

n, m, l = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()] for __ in range(n)]
B = [[int(_) for _ in input().split()] for __ in range(m)]

for row in matrixmult(A, B):
    print(' '.join([str(r) for r in row]))

Submission status: Runtime Error

Solution code:
n,m,l = [int(i) for i in input().split()]
a = [int(i) for i in input().split()] for j in range(n)]
b = [int(i) for i in input().split()] for j in range(m)]
c = [[0 for i in range(n)] for j in range(l)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for i in range(l):
    print(' '.join(map(str,c[i])))

Submission status: Runtime Error

Solution code:
n,m,l = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
b = [[int(i) for i in input().split()] for j in range(m)]
c = [[0 for i in range(n)] for j in range(l)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for i in range(l):
    print(' '.join(map(str,c[i])))

Submission status: Runtime Error

Solution code:
l, m, n = map(int,input().split())
a = [[0 for i in range(m)]for j in range(l)]
b = [[0 for i in range(n)]for j in range(m)]
c = [[0 for i in range(n)]for j in range(l)]

for i in range(l):
 for j in range(n):
  for k in range(m):
   c[i][j] += a[i][m] * b[m][j]
 print(" ".join([str(x) for x in c[i]]))

Submission status: Runtime Error

Solution code:
l, m, n = map(int,input().split())
a = [[0 for i in range(l)]for j in range(m)]
b = [[0 for i in range(m)]for j in range(n)]
c = [[0 for i in range(l)]for j in range(n)]

for i in range(l):
 for j in range(n):
  for k in range(m):
   c[i][j] += a[i][m] * b[m][j]
 print(" ".join([str(x) for x in c[i]]))

Submission status: Runtime Error

Solution code:
l, m, n = map(int,input().split())
a = [[0 for i in range(m)]for j in range(l)]
b = [[0 for i in range(n)]for j in range(m)]
c = [[0 for i in range(n)]for j in range(l)]

for i in range(l):
 a[i] = list(map(int, input().split()))

for i in range(m):
 b[i] = list(map(int, input().split()))

for i in range(l):
 for j in range(n):
  for k in range(m):
   c[i][j] += a[i][m] * b[m][j]
 print(" ".join([str(x) for x in c[i]]))

Submission status: Runtime Error

Solution code:
l, m, n = map(int,input().split())
a = [[0 for i in range(m)] for j in range(l)]
b = [[0 for i in range(n)] for j in range(m)]
c = [[0 for i in range(n)] for j in range(l)]

for i in range(l):
 a[i] = [int(x) for x in input().split()]

for i in range(m):
 b[i] = [int(x) for x in input().split()]

for i in range(l):
 for j in range(n):
  for k in range(m):
   c[i][j] += a[i][m] * b[m][j]
 print(" ".join([str(x) for x in c[i]]))

Submission status: Runtime Error

Solution code:
l, m, n = map(int,input().split())
a = [[0 for i in range(m)] for i in range(l)]
b = [[0 for i in range(n)] for i in range(m)]
c = [[0 for i in range(n)] for i in range(l)]

for i in range(l):
 a[i] = [int(x) for x in input().split()]

for i in range(m):
 b[i] = [int(x) for x in input().split()]

for i in range(l):
 for j in range(n):
  for k in range(m):
   c[i][j] += a[i][m] * b[m][j]
 print(" ".join([str(x) for x in c[i]]))

Submission status: Runtime Error

Solution code:
l, m, n = map(int,input().split())
a = [[0 for i in range(m)] for i in range(l)]
b = [[0 for i in range(n)] for i in range(m)]
c = [[0 for i in range(n)] for i in range(l)]

for i in range(l):
 a[i] = [int(x) for x in input().split()]

for i in range(m):
 b[i] = [int(x) for x in input().split()]

for i in range(l):
 for j in range(n):
  for k in range(m):
   c[i][j] += (a[i][m] * b[m][j])
 print(" ".join([str(x) for x in c[i]]))

Submission status: Runtime Error

Solution code:
# coding: utf-8
def main():
    n, m, l = map(int, raw_input().split())
    mat_A = [] # (n, m)
    mat_B = [] # (m, l)
    for i in range(n):
        mat_A.append(map(int, raw_input().split()))

    for j in range(m):
        mat_B.append(map(int, raw_input().split()))

    for i in range(n):
        c = [0 for g in range(n)]
        for j in range(l):
            for k in range(m):
              #  print "n:{}, m:{}, l:{}".format(i,k,j)
                c[j] += mat_A[i][k] * mat_B[k][j]
        print " ".join(map(str, c))
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
# coding: utf-8
 
n, m, l = map(int, raw_input().split())
mat_A = [] # (n, m)
mat_B = [] # (m, l)
for i in range(n):
    mat_A.append(map(int, raw_input().split()))
 
for j in range(m):
    mat_B.append(map(int, raw_input().split()))
 
for i in range(n):
    c = [0 for g in range(n)]
    for j in range(l):
        for k in range(m):
            c[j] += mat_A[i][k] * mat_B[k][j]
    print " ".join(map(str, c))

Submission status: Runtime Error

Solution code:
n,m,l=map(int,input().split())
matrix_a=[]
matrix_b=[]
matrix_c=[]
for i in range(n):
    matrix_a.append(list(map(int,input().split())))
for i in range(m):
    matrix_b.append(list(map(int,input().split())))
tmp_l=list()
for i in range(n):
    for j in range(l):
        tmp_n=0
        for k in range(m):
            tmp_n+=matrix_a[i][k]*matrix_b[k][j]
        tmp_l.append(tmp_n)
    matrix_c.append(tmp_l.copy())
    tmp_l.clear()
for a,b,c in matrix_c:
    print(a,b,c)

Submission status: Runtime Error

Solution code:
import numpy as np
x, y, z = map(int, input().split())
matrix1 = list()
matrix2 = list()
ans = list()
for i in range(x):
    matrix1.append(list(map(int, input().split())))
for i in range(y):
    matrix2.append(list(map(int, input().split())))
matrix1 = np.matrix(matrix1)
matrix2 = np.matrix(matrix2)
matrix3 = matrix1.dot(matrix2).tolist()
for i in range(x):
    print (' '.join(map(str, matrix3[i])))

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())
a = []
b = []
c = []
for i in range(n):
    c.append([0 for k in range(l)])
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(m):
    b.append(list(map(int, input().split())))
for s in range(n):
    for t in range(m):
        elm = 0
        for u in range(l):
            elm += a[s][t] * b[t][u]
        c[s][t] = elm
for i in c:
    print(" ".join(str, i))

Submission status: Runtime Error

Solution code:
#coding: utf-8

n, m, l = (int(i) for i in input().split())
nm = [[0 for i in range(m)] for j in range(n)]
ml = [[0 for i in range(l)] for j in range(m)]
nl = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    nm[i] = input().split()

for i in range(n):
    for j in range(m):
        nm[i][j] = int(nm[i][j])

for i in range(m):
    ml[i] = input().split()

for i in range(m):
    for j in range(l):
        ml[i][j] = int(ml[i][j])


for i in range(n):
    for j in range(l):
        for k in range(m):
            nl[j][i] += nm[i][k] * ml[k][j]

for i in range(n):
    for j in range(l):
        print(nl[j][i], end = ' ' if j != l-1 else '\n')

Submission status: Runtime Error

Solution code:
n, m, l = map(int,input().split())

x = []
y = []

for i in range(n):
    a = list(map(int,input().split()))
    x.append(a)
    
for i in range(m):
    b = list(map(int,input().split()))
    y.append(b)

#print(x)
a = 0
b = []
ans = []

for i in range(3):
    for j in range(3):
        for k in range(2):
            a += x[i][k]*y[k][j]
        #print(a)
        b.append(a)
        a = 0
    b = list(map(str, b))
    b = ' '.join(b)
    ans.append(b)
    b = []
        
[print(ans[i]) for i in range(len(ans))]

Submission status: Runtime Error

Solution code:
n, m, l = map(int,input().split())

x = []
y = []

for i in range(n):
    a = list(map(int,input().split()))
    x.append(a)
    
for i in range(m):
    b = list(map(int,input().split()))
    y.append(b)

#print(x)
a = 0
b = []
ans = []

for i in range(n):
    for j in range(m):
        for k in range(l):
            a += x[i][k]*y[k][j]
        #print(a)
        b.append(a)
        a = 0
    b = list(map(str, b))
    b = ' '.join(b)
    ans.append(b)
    b = []
        
[print(ans[i]) for i in range(len(ans))]

Submission status: Runtime Error

Solution code:
n,m,l = map(int,input().split())
n_list=[] 
m_list = []
c=[[0 for i in range(n)] for j in range(l)]
for i in range(n):
    n_list.append([int(i) for i in input().split()])
for j in range(m):
    m_list.append([int(i) for i in input().split()])
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j]+=n_list[i][k]*m_list[k][j]

for i in range(n):
    print(' '.join(str(i) for i in c[i]))

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for j in range(m):
    b.append(list(map(int, input().split())))

c = [[0 for k in range(l)] for i in range(n)]
for i in range(n):
    for k in range(l):
        for j in range(m):
            c[i][k] += a[i][j]*b[j][k] 
 for i in range(n):
    print(c[i])

Submission status: Runtime Error

Solution code:
n, m, l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for j in range(m):
    b.append(list(map(int, input().split())))

c = [[0 for k in range(l)] for i in range(n)]
for i in range(n):
    for k in range(l):
        for j in range(m):
            c[i][k] += int(a[i][j]*b[j][k] )
 for i in range(n):
    print(c[i])

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

n, m, l = list(map(int, input().split()))
a = []
b = []

for i in range(n):
    a.append(list(map(int, input().split())))

for i in range(m):
    b.append(list(map(int, input().split())))

for i in range(n):
    for j in range(l):
        mat_sum = 0
        for k in range(m):
            mat_sum += a[n][m] * b[m][l]
        print('{0} '.format(mat_sum), end='')
    print()