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: Accepted

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 = [[0 for _ in range(l)] for _ in range(n)]

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

for i in c:
    print(" ".join(list(map(str,i))))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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: Accepted

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)]

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

Submission status: Accepted

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(n):
    print(" ".join([str(s) for s in C[li]]))

Submission status: Accepted

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(n):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Accepted

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(n):
    print(" ".join([str(s) for s in C[li]]))

Submission status: Accepted

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(n):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Accepted

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(n):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Accepted

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(n):
     print(" ".join([str(s) for s in C[ni]]))

Submission status: Accepted

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(n):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Accepted

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(aaa * bk for aaa, bk in zip(ar,bbb)) for bbb in zip(*b)] for ar in a]
  
for ccc in c:
    print(*ccc)

Submission status: Accepted

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(n):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Accepted

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(n):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Accepted

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(n):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Accepted

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(n):
    print(" ".join([str(s) for s in C[ni]]))

Submission status: Accepted

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

A = [[int(s) for s in input().split()] for i in range(n)]
B = [[int(s) for s in input().split()] for i in range(m)]

for x in range(n):
    o = []
    for y in range(l):
        sum = 0
        for z in range(m):
            sum += A[x][z] * B[z][y]
        o.append(str(sum))
    print(" ".join(o))

Submission status: Accepted

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

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

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in c:
    print(*i)

Submission status: Accepted

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)]
for i in range(n):
    for j in range(l):
        print(sum(a[i][k] * b[k][j] for k in range(m)), end='')
        if j != l - 1:
            print(' ', end='')
    print('')

Submission status: Accepted

Solution code:
NML = input().split()
n = int(NML[0])
m = int(NML[1])
l = int(NML[2])

A = []
B = []
for i in range(n):
    A.append([])
    A_r = input().split()
    for j in range(m):
        A[i].append(int(A_r[j]))
for i in range(m):
    B.append([])
    B_r= input().split()
    for j in range(l):
        B[i].append(int(B_r[j]))
for i in range(n):
    for j in range(l):
        out=0
        for k in range(m):
            out +=A[i][k]*B[k][j]
        print(str(out),end="")
        if j != l-1:
            print(" ",end="")
    print("")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def makeEmptyMatrix(i, j):
	mat = [[]] * i
	for a in xrange(i):
		mat[a] = [0] * j
	return mat

n, m, l = map(int, raw_input().split())
A = makeEmptyMatrix(n, m)
B = makeEmptyMatrix(l, m)
for i in xrange(n):
 A[i] = map(int, raw_input().split())

for i in xrange(m):
 for j, v in enumerate(map(int, raw_input().split())):
  B[j][i] = v

for a in A:
 for b in B:
  ttl = 0
  for i, j in zip(a, b): ttl += i*j
  print ttl,
 print

Submission status: Accepted

Solution code:
# ????????????????±???????????????°??????
import sys

def mul_matrix(a, b):
    n = len(a)
    m = len(b)
    l = len(b[0])
    
    ans = []

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

            new_row.append(sum)

        ans.append(new_row)
    
    return ans

def main():
    n, m, l = [int(i) for i in sys.stdin.readline().strip().split(' ')]
    
    a = []
    b = []
    
    for i in range(n):
        data = [int(j) for j in sys.stdin.readline().strip().split(' ')]
        a.append(data)

    for i in range(m):
        data = [int(j) for j in sys.stdin.readline().strip().split(' ')]
        b.append(data)

    ans = mul_matrix(a, b)

    for i in ans:
        print(' '.join([str(j) for j in i]))
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m,l = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(n)]
B = [map(int,input().split()) for i in range(m)]
B_T = list(map(list, zip(*B)))
for a in A:
    row = []
    for b in B_T:
        row.append(sum([x*y for (x,y) in zip(a,b)]))
    print(' '.join(map(str,row)))

Submission status: Accepted

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

A = [[0] for i in range(n)]
B = [[0] for i in range(m)]
temp = 0

for i in range(n):
    A[i] = map(int, raw_input().split())
for i in range(m):
    B[i] = map(int, raw_input().split())

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

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

Submission status: Accepted

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 = [[sum(ak*bk for ak, bk in zip(ai, bj)) for bj in zip(*b)] for ai in a]

for ci in c:
    print(*ci)

Submission status: Accepted

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.append(list(map(int, input().split())))

for x in range(m):
	B.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: Accepted

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

A = []
B = []
AB = [[]for i in range(n)]
for i in range(n):
    A.append(map(int,raw_input().split()))
for j in range(m):
    B.append(map(int,raw_input().split()))

for i in range(n):
    for k in range(l):
        sum = 0
        for j in range(m):
            sum += A[i][j]* B[j][k]
        AB[i].append(sum)
for i in range(n):
    print ("{}".format(AB[i]).replace("[","").replace(",","").replace("]",""))

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

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)]
for i in range(n):
    r = []
    for j in range(l):
        c = 0
        for k in range(m):
            c += A[i][k] * B[k][j]
        r.append(c)
    print(*r)

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(n)]
B = [tuple(map(int, input().split())) for _ in range(m)]
B_T = [tuple(r) for r in zip(*B)]
for L in ((sum((a*b for a, b in zip(ai, bj))) for bj in B_T) for ai in A):
    print(*L)

Submission status: Accepted

Solution code:
n,m,l = list(map(int,input().split()))
matrix_a = [list(map(int,input().split())) for i in range(n)]
matrix_b = [list(map(int,input().split())) for i in range(m)]
matrix_b = [list(x) for x in zip(*matrix_b)]

for i in range(n):
    line = []
    for j in range(l):
        line.append(sum([x*y for (x,y) in zip(matrix_a[i],matrix_b[j])]))
    print(' '.join(list(map(str,line))))

Submission status: Accepted

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 = [ [sum([A[k][j] * B[j][i] for j in range(m)]) for i in range(l)] for k in range(n)]

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

Submission status: Accepted

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

A = []
B = []
C = []
counter = 0
while counter < n:
    A.append([int(x) for x in raw_input().split()])
    counter += 1

counter = 0
while counter < m:
    B.append([int(x) for x in raw_input().split()])
    counter += 1

counter = 0
while counter < n:
    C.append([0] * l)
    counter += 1

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 data in C:
    print(' '.join([str(x) for x in data]))

Submission status: Accepted

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

A = []
B = []
counter = 0
while counter < n:
    A.append([int(x) for x in raw_input().split()])
    counter += 1

counter = 0
while counter < m:
    B.append([int(x) for x in raw_input().split()])
    counter += 1

B = list(zip(*B))

for i in range(n):
    data = []
    for j in range(l):
        data.append(sum([x[0] * x[1] for x in zip(A[i], B[j])]))
    print(' '.join([str(x) for x in data]))

Submission status: Accepted

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

A = []
B = []
counter = 0
while counter < n:
    A.append([int(x) for x in raw_input().split()])
    counter += 1

counter = 0
while counter < m:
    B.append([int(x) for x in raw_input().split()])
    counter += 1

B = list(zip(*B))

for i in range(n):
        print(' '.join([str(x) for x in [sum([x[0] * x[1] for x in zip(A[i], B[j])]) for j in range(l)]]))

Submission status: Accepted

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(l)] for j in range(n)]
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: Accepted

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

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

for i in range(0,n):
    c[i] = [str(c[i][j]) for j in range(0,l)]
    print(' '.join(c[i]))

Submission status: Accepted

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

a = []
b = []
for _ in range(n):
  a.append([int(__) for __ in input().split()])

for _ in range(m):
  b.append([int(__) for __ in input().split()])

output_list = []
for ac in a:
  output = []
  for bc in zip(*b):
    output.append(sum([acc*bcc for acc, bcc in zip(ac,bc)]))
  output_list.append(output)

for olist in output_list:
  print(" ".join([str(_) for _ in olist]))

Submission status: Accepted

Solution code:
def calc_matrix(A, B, size):
    n, m, l = size
    # print(n, m, l)

    results = []
    for i in range(n):
        row_data = []
        for j in range(l):
            products = []
            for k in range(m):
                products.append(A[i][k] * B[k][j])
            # print('C[{0}][{1}] = {2}'.format(i, j, sum(products)))
            row_data.append(sum(products))
        results.append(row_data)
    return results


if __name__ == '__main__':
    # ??????????????\???
    A = []
    B = []
    # A.append([1, 2])
    # A.append([0, 3])
    # A.append([4, 5])
    # B.append([1, 2, 1])
    # B.append([0, 3, 2])
    n, m, l = [int(x) for x in input().split(' ')]
    for i in range(n):
        A.append([int(x) for x in input().split(' ')])
    for i in range(m):
        B.append([int(x) for x in input().split(' ')])

    # ???????????????
    results = calc_matrix(A, B, (n, m, l))

    # ???????????????
    for row in results:
        print(' '.join(map(str, row)))

Submission status: Accepted

Solution code:
n,m,l=map(int, input().split())
A=[ [ int(a) for a in input().split() ] for i in range(n) ]
B=[ [ int(b) for b in input().split() ] for i in range(m) ]
Bt=[ list(x) for x in zip(*B) ]
for a in A:
    print(" ".join(map(str, [ sum([ x*y for x,y in zip(a,b) ]) for b in Bt ])))

Submission status: Accepted

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())))

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

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

for i in res:
	print(" ".join(list(map(str,i))))

Submission status: Accepted

Solution code:
n,m,l=map(int,raw_input().split())
A=[]
B=[]
for i in range(n):
    A.append(map(int,raw_input().split()))
for i in range(m):
    B.append(map(int,raw_input().split()))
for i in range(n):
    print(' '.join(map(str,[sum([A[i][j]*B[j][k] for j in range(m)]) for k in range(l)])))

Submission status: Accepted

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

A = [0] * n
for i in range(n):
    A[i] = [int(x) for x in input().split(' ')]
B = [0] * m
for i in range(m):
    B[i] = [int(x) for x in input().split(' ')]

def tranpose(matrix):
    r, c = len(matrix), len(matrix[0])
    return [[row[i] for row in matrix] for i in range(c)]

B = tranpose(B)
C = [[0 for _ in range(l)] for _ in range(n)]

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

for row in C:
    print(*row, sep=' ')

Submission status: Accepted

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)]
for ARow in A:
    result = []
    for BCol in zip(*B):
        result.append(sum([ARow[i] * BCol[i] for i in range(m)]))
    print(*result)

Submission status: Accepted

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)]
for ARow in A:
    result = []
    for BCol in zip(*B):
        result.append(sum([a * b for (a,b) in zip(ARow, BCol)]))
    print(*result)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

a = [0]*n
b = [0]*m
c = [[0 for col in range(l)] for row in range(n)]

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

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


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

Submission status: Accepted

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

a = [0]*n
b = [0]*m
c = [[0 for col in range(l)] for row in range(n)]

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

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


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

Submission status: Accepted

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

a = [0]*n
b = [0]*m
c = [[0 for col in range(l)] for row in range(n)]

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

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

#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):
    c[i] = [sum([a[i][k]*b[k][j] for k in range(m)]) for j in range(l)]
    print(*c[i])

Submission status: Accepted

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

#a = [0]*n
#b = [0]*m
#c = [[0 for col in range(l)] for row in range(n)]

#for i in range(n):
#    a[i] = list(map(int,input().split()))
#for i in range(m):
#    b[i] = list(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)]

#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(*[sum([a[i][k]*b[k][j] for k in range(m)]) for j in range(l)])

Submission status: Accepted

Solution code:
n, m, l = list(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)]

for i in range(n):
    print(*[sum([a[i][k]*b[k][j] for k in range(m)]) for j in range(l)])

Submission status: Accepted

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 j in range(l)] for i in range(n)]

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: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
a=b=ab=[]
n, m, l = map(int, input().strip().split())
for i in range(m+n):
    ab.append(list(map(int, input().strip().split())))
a,b=ab[:n],ab[n:]
for i in range(n):
    c = [sum(a[i][k]*b[k][j] for k in range(m)) for j in range(l)]
    print(*c)

Submission status: Accepted

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

for i in range(n):
    row = list(map(int,input().split()))
    for j in range(m):
        a[i][j] = row[j]

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

c = [[0 for i2 in range(l)] for i1 in range(n)]

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):
    for j in range(l-1):
        print(c[i][j],end = ' ')
    print(c[i][-1])

Submission status: Accepted

Solution code:
import sys

lines = [list(map(int,line.split())) for line in sys.stdin]
n,m,l = lines[0]

A = lines[1:n+1]
B = [i for i in zip(*lines[n+1:])]

for a in A:
    row = []
    for b in B:
        row.append(sum([i*j for i,j in zip(a,b)]))
    print (" ".join(map(str,row)))

Submission status: Accepted

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)]
[print(*x) for x in [[sum(j*k for j,k in zip(x,y)) for y in zip(*b)] for x in a]]

Submission status: Accepted

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

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

for i in range(n):
        print(" ".join(map(str,result[i])))

Submission status: Accepted

Solution code:
#!usr/bin/env python3

import sys


def multiply_matrix_a_b():
    n, m, l = [int(i) for i in sys.stdin.readline().split()]
    matrix_a = [[0 for col in range(m)] for row in range(n)]
    matrix_b = [[0 for col in range(l)] for row in range(m)]
    matrix_res = [[0 for col in range(l)] for row in range(n)]

    for row in range(n):
        lst = [int(element) for element in sys.stdin.readline().split()]
        for col in range(m):
            matrix_a[row][col] += lst[col]

    for row in range(m):
        lst = [int(element) for element in sys.stdin.readline().split()]
        for col in range(l):
            matrix_b[row][col] += lst[col]

    for row_a in range(len(matrix_a)):
        for col_a in range(len(matrix_b[0])):
            for row_b in range(len(matrix_b)):
                matrix_res[row_a][col_a] += \
                        matrix_a[row_a][row_b] * matrix_b[row_b][col_a]

    return matrix_res


def main():
    [print(*row) for row in multiply_matrix_a_b()]


if __name__ == '__main__':
    main()

Submission status: Accepted

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(n):
	for j in range(l):
		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: Accepted

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

Submission status: Accepted

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 j in range(l)]for i in range(n)]
    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: Accepted

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

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

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

    print(" ".join([str(_) for _ in C[i]]))