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())
matrix_a = [list(map(int, input().split())) for i in range(n)]
matrix_b = [list(map(int, input().split())) for i in range(m)]
mul_matrix_a_b = [[sum([matrix_a[i][k] * matrix_b[k][j] for k in range(m)]) for j in range(l)] for i in range(n)]
for result in mul_matrix_a_b:
    print(*result)

Submission status: Accepted

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

A = [0]*n*m
for k in xrange(n):
    A[k*m:k*m+m] = map(int, raw_input().split())

B = [0]*m*l
for k in xrange(m):
    B[k*l:k*l+l] = map(int, raw_input().split())

C = [0]*n*l
for i in xrange(n):
    for j in xrange(l):
        for k in xrange(m):
            C[i*l + j] += A[i*m + k] * B[k*l + j]
        if j < l-1:
            print C[i*l + j],
        else:
            print C[i*l + j]

Submission status: Accepted

Solution code:
intInput = lambda: map(int, raw_input().split())
n, m, l = intInput()
A = [intInput() for _ in xrange(n)]
B = [intInput() for _ in xrange(m)]
for i in xrange(n):
    for j in xrange(l):
        print sum([A[i][k] * B[k][j] for k in xrange(m)]),
    print

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 = []
B_T = list(zip(*B))
for a_row in A:
    C.append([sum(a * b for a, b, in zip(a_row, b_column)) for b_column in B_T])
for row in C:
    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)]

C = []
B_T = list(zip(*B))
for a_row in A:
    C.append([sum(a * b for a, b, in zip(a_row, b_column)) for b_column in B_T])
for row in C:
    print(' '.join(map(str, row)))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
(n, m, l) = [int(i) for i in input().split()]
 
A = []
for nc in range(n):
    A.append([int(i) for i in input().split()])
 
B = []
for mc in range(m):
    B.append([int(i) for i in input().split()])
 
product = [[0 for d in range(l)] for dd in range(n)]
 
for nc in range(n):
    for lc in range(l):
        for mc in range(m):
            product[nc][lc] += A[nc][mc] * B[mc][lc]
 
for r in product:
    print(' '.join([str(d) for d in r]))

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] * l for i in range(n)]
 
for i in range(n):
    for j in range(l):
        C[i][j] = str(sum(A[i][k] * B[k][j] for k in range(m)))
 
for i in range(n):
    print(' '.join(C[i]))

Submission status: Accepted

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

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

for x in range(n):
    c = []
    for y in range(l):
        d = 0
        for z in range(m):
            d += a[x][z] * b[z][y]
        c.append(str(d))
    print(' '.join(c))

Submission status: Accepted

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

for x in range(n):
    c = []
    for y in range(l):
        d = 0
        for z in range(m):
            d += a[x][z] * b[z][y]
        c.append(str(d))
    print(' '.join(c))

Submission status: Accepted

Solution code:
(n, m, l) = [int(i) for i in input().split()]
A = []
for nc in range(n): 
    A.append([int(i) for i in input().split()])
B = []
for mc in range(m): 
    B.append([int(i) for i in input().split()])

product = [[0 for d in range(l)] for dd in range(n)]
      
for nc in range(n):
    for lc in range(l): 
        for mc in range(m):
            product[nc][lc] += A[nc][mc] * B[mc][lc] 

for r in product: 
    print(' '.join([str(d) for d in r]))

Submission status: Accepted

Solution code:
first_line = raw_input().split(" ")
n = int(first_line[0])
m = int(first_line[1])
l = int(first_line[2])

array_a = []
array_b = []
for i in xrange(n):
  line = map(int, raw_input().split(" "))
  array_a.append(line)
for i in xrange(m):
  line = map(int, raw_input().split(" "))
  array_b.append(line)

# print array_a
# print array_b

array_c = []
for i in xrange(n):
  line = []
  for j in xrange(l):
    sum = 0
    for k in xrange(m):
      sum += array_a[i][k] * array_b[k][j]
    line.append(sum)
  array_c.append(line)

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

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 = []
B_T = list(zip(*B))
for a_row in A:
    C.append([sum(a * b for a, b, in zip(a_row, b_column)) for b_column in B_T])
for row in C:
    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)]
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 = [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(*ci)

Submission status: Accepted

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

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

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(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:
if __name__ == '__main__':
	n,m,l=map(int,raw_input().split())
	a=[map(int,raw_input().split()) for _ in xrange(n)]
	b=zip(*[map(int,raw_input().split()) for _ in xrange(m)])
	sums=[i[k]*j[k] for i in a for j in b for k in xrange(m)]
	c=[sum(sums[i:i+m]) for i in [j for j in xrange(len(sums)) if j%m==0]]
	for i in xrange(len(c)):
		if (i+1)%l==0: print c[i]
		else: print c[i],

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	n,m,l=map(int,raw_input().split())
	a=[map(int,raw_input().split()) for _ in [0]*n]
	b=zip(*[map(int,raw_input().split()) for _ in [0]*m])
	sums=[i[k]*j[k] for i in a for j in b for k in xrange(m)]
	c=[sum(sums[i:i+m]) for i in [j for j in xrange(len(sums)) if j%m==0]]
	for i in xrange(len(c)):
		if (i+1)%l==0: print c[i]
		else: print c[i],

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	n,m,l=map(int,raw_input().split())
	a=[map(int,raw_input().split()) for _ in [0]*n]
	b=zip(*[map(int,raw_input().split()) for _ in [0]*m])
	sums=[i[k]*j[k] for i in a for j in b for k in xrange(m)]
	c=[sum(sums[i:i+m]) for i in [j for j in xrange(len(sums)) if j%m==0]]
	c=[c[i:i+l] for i in xrange(len(c)) if i%l==0]
	for i in c:
		print " ".join(map(str, i))

Submission status: Accepted

Solution code:
N, M, L = map(int, raw_input().split())
nm = [map(int, raw_input().split()) for n in range(N)]
ml = [map(int, raw_input().split()) for m in range(M)]

ml_t = []
for l in range(L):
    tmp = []
    for m in range(M):
        tmp.append(ml[m][l])
    ml_t.append(tmp)

for n in range(N):
    tmp1 = nm[n]
    col = [0]*L
    for l in range(L):
        tmp2 = ml_t[l]
        for m in range(M):
            col[l] += tmp1[m] * tmp2[m]
    print ' '.join(map(str, col))

Submission status: Accepted

Solution code:
N, M, L = map(int, raw_input().split())
nm = [map(int, raw_input().split()) for n in range(N)]
ml = [map(int, raw_input().split()) for m in range(M)]

for n in range(N):
    col = [0] * L
    for l in range(L):
        for m in range(M):
            col[l] += nm[n][m] * ml[m][l]
    print ' '.join(map(str, col))

Submission status: Accepted

Solution code:
import sys

n,m,l=map(int,raw_input().split())
list1 = [[0 for i in range(m)]for i in range(n)]
list2 = [[0 for i in range(l)]for i in range(m)]
list3 = [[0 for i in range(l)]for i in range(n)]
for i in range(n):
	list1[i] = map(int,raw_input().split())
for i in range(m):
	list2[i] = map(int,raw_input().split())
for i in range(n):
	for j in range(l):
		for k in range(m):
			list3[i][j] += list1[i][k] * list2[k][j]
for i in range(n):
	for j in range(l):
		if j==l-1:
			print'%d' %list3[i][j]
		else:
			sys.stdout.write(str(list3[i][j]))
			sys.stdout.write(' ')

Submission status: Accepted

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

A = []
B = []
C = [[] for i in range(n)]

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

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

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

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

Submission status: Accepted

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

A = []
B = []
C = [[] for i in range(n)]

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

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

for i in range(n):
    for j in range(l):
        ab = sum([A[i][k] * B[k][j] for k in range(m)])
        if j == (l - 1):
            print(ab)
        else:
            print(ab, end = ' ')

Submission status: Accepted

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

A = []
B = []
C = [[] for i in range(n)]

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

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

for i in range(n):
    line = ""
    for j in range(l):
        ab = sum([A[i][k] * B[k][j] for k in range(m)])
        line += " {0}".format(ab)
    print(line[1:])

Submission status: Accepted

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

A = []
B = []
C = [[] for i in range(n)]

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

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

for i in range(n):
    for bj in zip(*B):
        c = sum(aik * bjk for aik, bjk in zip(A[i], bj))
        C[i].append(c)
        
for i in C:
    print(*i)

Submission status: Accepted

Solution code:
in_line = raw_input().split()
n = int(in_line[0])
m = int(in_line[1])
l = int(in_line[2])
a = []
b = []
for i in range(0,n):
    in_line = raw_input().split()
    a.append([])
    for j in range(0,m):
        a[i].append(int(in_line[j]))
for i in range(0,m):
    in_line = raw_input().split()
    b.append([])
    for j in range(0,l):
        b[i].append(int(in_line[j]))
for i in range(0,n):
    for j in range(0,l):
        col = 0
        for k in range(0,m):
            col += a[i][k]*b[k][j]
        if j == l-1:
            print col
        else:
            print col,

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

for i in range(n):
    for j in range(l):
        s = 0
        for k in range(m):
            s += A[i][k] * B[k][j]
        print(s, end='')
        if j != l-1:
            print(' ', end='')
    print()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def show2dlist(nlist,r,c):
    for x in xrange(0,r):
        nlist[x] = map(str,nlist[x])
        ans = " ".join(nlist[x])
        print ans
# input
n,m,l = map(int,raw_input().split())
a_matrix = [[0 for x in xrange(m)] for y in xrange(n)]
b_matrix = [[0 for x in xrange(l)] for y in xrange(m)]
for x in xrange(n):
    a_matrix[x] = map(int,raw_input().split())
for x in xrange(m):
    b_matrix[x] = map(int,raw_input().split())

c_matrix = [[0 for x in xrange(l)] for y in xrange(n)]

# calc
for ni in xrange(n):
    for li in xrange(l):
        for mi in xrange(m):
            c_matrix[ni][li] += a_matrix[ni][mi] * b_matrix[mi][li]

# show result
show2dlist(c_matrix,n,l)

Submission status: Accepted

Solution code:
# coding: utf-8

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

A = []
B = []

# ??????A???????´?
for i in range(n):
    row = list(map(int, input().split()))
    A.append(row)

# ??????B???????´?
for i in range(m):
    row = list(map(int, input().split()))
    B.append(row)


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

for r in range(n):
    print(' '.join(map(str, C[r])))

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
a = []
b = []
n, m, l = [int(n) for n in input().split()]
c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    a.append([int(n) for n in input().split()])
for i in range(m):
    b.append([int(n) for n in 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 num in c:
    print(' '.join(str(n) for n in num))

Submission status: Accepted

Solution code:
from operator import mul
from itertools import starmap

n, m, l = map(int, input().split())
a, b = ([tuple(map(int, input().split())) for _ in range(k)] for k in (n, m))
for line in ([sum(starmap(mul, zip(ai, bj))) for bj in zip(*b)] for ai in a):
    print(*line)

Submission status: Accepted

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

for _ in range(m):
	B.append(input().split())

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

Submission status: Accepted

Solution code:
def set_matrix (num,matrix):
    for i in xrange(num):
        x = map(int,raw_input().split(" "))
        matrix.append(x)

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

a = []
b = []
set_matrix(n,a)
set_matrix(m,b)

b_t = list(map(list,zip(*b)))

for i in xrange(n):

    result = []
    for j in xrange(l):
        result.append( sum([x*y for x,y in zip(a[i], b_t[j]) ]))
    print " ".join(map(str,result))

Submission status: Accepted

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

mat1 = {}
mat2 = {}

n, m, l = map(int, raw_input().split())
for i in range(1, n+1):
    list = map(int, raw_input().split())
    for j in range(1, m+1):
        mat1[(i, j)] = list[j-1]

for j in range(1, m+1):
    list = map(int, raw_input().split())
    for k in range(1, l+1):
        mat2[(j, k)] = list[k-1]

for i in range(1, n+1):
    buf = ""
    for k in range(1, l+1):
        res = 0
        for j in range(1, m+1):
            res += mat1[(i, j)]*mat2[(j, k)]
        buf += str(res) +" "
    buf = buf.rstrip()
    print buf

Submission status: Accepted

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

C = []
for lines in range(n):
    C.append([sum([A[lines][i] * B[i][j] for i in range(m)]) for j in range(l)])
    print(" ".join(map(str, C[lines])))

Submission status: Accepted

Solution code:
n,m,l = map(int,raw_input().split())
a = [map(int,raw_input().split()) for _ in range(n)]
b = [map(int,raw_input().split()) for _ 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):
        s = 0
        for k in range(m):
            s += a[i][k] * b[k][j]
        c[i][j] = s

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 _ in range(n)]
B = [list(map(int, input().split())) for _ in range(m)]
ans = []
for i in range(n):
    new_row = []
    for j in range(l):
        tmp_ans = 0
        for k in range(m):
            tmp_ans += A[i][k] * B[k][j]
        new_row.append(tmp_ans)
    ans.append(new_row)

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

Submission status: Accepted

Solution code:
import sys

N, M, L = map(int, raw_input().split())
a = []
b = []
for n in range(N):
	a.append(map(int, raw_input().split()))
for m in range(M):
	b.append(map(int, raw_input().split()))

c = [[0 for l in xrange(L)] for n in xrange(N)]

for n in xrange(N):
	for l in xrange(L):
		for m in xrange(M):
			c[n][l] += a[n][m] * b[m][l]

for n in xrange(N):
	for l in xrange(L-1):
		sys.stdout.write(str(c[n][l])+" ")
	print c[n][L-1]

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 i 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 range(n):
    print(' '.join(map(str, c[i])))

Submission status: Accepted

Solution code:
#   n??m????????? A ??¨ m??l ????????? B ?????\??????????????????????????§?????? n??l ????????? C ???????????????????????°??????
n, m, l = map(int, input().split())
#   n x m ???????????????
A = [[0 for i in range(m)] for j in range(n)]
#   m x l ???????????????
B = [[0 for i in range(l)] for j in range(m)]
#   n x l ??????(????????????)?????????
C = [[0 for i in range(l)] for j in range(n)]

#   m x n ??????????¨??????\?????????????????????
for i in range(0, n):
    A[i][:m] = map(int, input().split())
    #   print(sheet_nxm)
#   m x n ??????????¨??????\?????????????????????
for i in range(0, m):
    B[i][:l] = map(int, input().split())
    #   print(sheet_mxl)
#   C(n x l)??????????¨???????A????????¨B????????????
for i in range(0, n):
    for j in range(0, l):
        for k in range(0, m):
            C[i][j] += A[i][k] * B[k][j]
#   print(C)
#   C???????????????
for i in range(0, n):
    for j in range(0, l):
        print("{0}".format(C[i][j]), end="")
        if j != l - 1:
            print(" ", end="")
        else:
            print("")

Submission status: Accepted

Solution code:
# 14-Structured_Program_II-Matrix_Multiplication.py

# ????????????

# n??m????????? AA ??¨ m??l????????? B ?????\??????????????????????????§?????? n??l ????????? C ???????????????
# ????????°????????????????????????????????????
# ?????? C ??????????´? cij ????¬?????????§??????????????????

# cij=???{k=1,m}aik bkj
# ????????§???A???B???C ??????????´???????????????? aij???bij???cij ??¨????????????

# Input
# ???????????? n???m???l ????????????????????§?????????????????????
# ?¶?????????? n??m ????????? A ??¨ m??l ????????? B ????????????????????????

# Output
# n??l ????????? C ???????´? cij ??????????????????????????????
# ???????????£?????????????´?????????????????????§????????£??????????????????

# Constraints
# 1???n,m,l???100
# 0???aij,bij???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

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


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):
	# print("i:{0}".format(i))
	for j in range(l):
		# print("j:{0}".format(j))
		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("{0}".format(c[i][j]))
		else:
			print("{0} ".format(c[i][j]), end="")

Submission status: Accepted

Solution code:
(n, m, l) = [int(i) for i in input().split()]
A = []
for nc in range(n):
    A.append([int(i) for i in input().split()])
B = []
for mc in range(m):
    B.append([int(i) for i in input().split()])

product = [[0 for d in range(l)] for dd in range(n)]

for nc in range(n):
    for lc in range(l):
        for mc in range(m):
            product[nc][lc] += A[nc][mc] * B[mc][lc]

for r in product:
    print(' '.join([str(d) for d in r]))

Submission status: Accepted

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

#??\?????????????????????????´?
for i in range(n):
    #swap_list = input().split()
    #A.append(swap_list)
    A.append([int(i) for i in input().split()])
for i in range(m):
    #swap_list = input().split()
    #B.append(swap_list)
    B.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] += A[i][k] * B[k][j]
#?????????????????????
#for i in range(n):
#    for j in range(l):
#        print("{0}".format(C[i][j]), end="\b")
#    print("")
#for i in range(n):
#    print(" ".join(map(str, C[i][:])))
for r in C:
    print(" ".join([str(d) for d in r]))

Submission status: Accepted

Solution code:
n, m, l = (int(i) for i in input().split())
A = []
B = []
#C = [[0] * n] * l
C = [[0 for i in range(l)] for j in range(n)]
#??\?????????????????????????´?
for i in range(n):
    #swap_list = input().split()
    #A.append(swap_list)
    A.append([int(i) for i in input().split()])
for i in range(m):
    #swap_list = input().split()
    #B.append(swap_list)
    B.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] += A[i][k] * B[k][j]
#?????????????????????
#for i in range(n):
#    for j in range(l):
#        print("{0}".format(C[i][j]), end="\b")
#    print("")
for i in range(n):
    print(" ".join(map(str, C[i][:])))
#for r in C:
#    print(" ".join([str(d) for d in r]))

Submission status: Accepted

Solution code:
n, m, l = (int(i) for i in input().split())
A = []
B = []
C = [[0 for i in range(l)] for j in range(n)]
#??\?????????????????????????´?
for i in range(n):
    swap_list = input().split()
    A.append(swap_list)
    #A.append([int(i) for i in input().split()])
for i in range(m):
    swap_list = input().split()
    B.append(swap_list)
    #B.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] += int(A[i][k]) * int(B[k][j])
#?????????????????????
#for i in range(n):
#    for j in range(l):
#        print("{0}".format(C[i][j]), end="\b")
#    print("")
for i in range(n):
    print(" ".join(map(str, C[i][:])))
#for r in C:
#    print(" ".join([str(d) for d in r]))

Submission status: Accepted

Solution code:
n,m,l=map(int,input().split())
mat = [ list(map(int,input().split())) for _ in range(0,n) ]
mat2 = [ list(map(int,input().split())) for _ in range(0,m) ]
mat3 = [ [ 0 for _ in range(0,l) ] for _ in range(0,n) ]
for i in range(0,n):
    for j in range(0,m):
        for k in range(0,l):
            mat3[i][k] += mat[i][j] * mat2[j][k];
for xs in mat3:
    print(' '.join(map(str, xs)))

Submission status: Accepted

Solution code:
n,m,l = map(int,input().split())
matrixA = [list(map(int,input().split())) for i in range(n)]
matrixB = [list(map(int,input().split())) for i in range(m)]
 
matrixAxB = [list(sum([matrixA[i][k] * matrixB[k][j] for k in range(m)]) for j in range(l)) for i in range(n)]
 
for row in matrixAxB:
    print(*row)

Submission status: Accepted

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

#Output
for i in c:
    print(*i)

Submission status: Accepted

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())))
for A_r in A:
    print(" ".join(map(str,[sum([x*y for x,y in zip(A_r,[B_r[k] for B_r in B])]) for k in range(l)])))

Submission status: Accepted

Solution code:
n,m,l=map(int,raw_input().split())
a=[]
b=[]
c=[[0 for k in range(l)] 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):
		for j in range(m):
			c[i][k] += a[i][j]*b[j][k]
for i in range(n):
	print ' '.join(map(str,c[i]))

Submission status: Accepted

Solution code:
import sys
import math

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

A = [[0 for i in xrange(m)] for j in xrange(n)]
B = [[0 for i in xrange(l)] for j in xrange(m)]

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

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

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

        sys.stdout.write(str(sm))
        if j < l-1:
            sys.stdout.write(" ")
    print

Submission status: Accepted

Solution code:
import sys
import math

n, m, l = map(int, raw_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)]

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

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

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

        sys.stdout.write(str(sm))
        if j < l-1:
            sys.stdout.write(" ")
    print

Submission status: Accepted

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

matrix = []
for i in range(l):
	mtr = []
	for j in range(m):
		mtr.append(matrixB[j][i])
	matrix.append(mtr)

matrixC = []
for i in range(l):
	mtr = []
	for j in range(n):
		num_sum = 0
		# print(matrixA[j],matrix[i])
		for a,b in zip(matrixA[j],matrix[i]):
			num_sum += a*b
		mtr.append(num_sum)
	matrixC.append(mtr)

matrix = []
for i in range(n):
	out = ''
	for j in range(l):
		out += str(matrixC[j][i]) + ' '
	print(out[:-1])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,m,l = [int(i)for i in input().split(' ')]
A = []
B = []
C = [[0for _ in range(l)]for _ in range(n)]
for i in range(n):
    A.append([int(a)for a in input().split(' ')])
for i in range(m):
    B.append([int(a)for a in input().split(' ')])

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

for x in range(n):
    print(' '.join([str(a)for a in C[x]]))

Submission status: Accepted

Solution code:

#def area#################
def zero(n,m):
	A=list()
	for i in range(n):
		A+=[[0]*m]
	return A
##########################

k=map(int,raw_input().split(" "))

A=zero(k[0],k[1])
B=zero(k[1],k[2])
C=zero(k[0],k[2])

#A_set
for i in range(k[0]):
	ipt=map(int,raw_input().split(" "))
	for j in range(k[1]):
		A[i][j]+=ipt[j]
#B_set
for i in range(k[1]):
	ipt=map(int,raw_input().split(" "))
	for j in range(k[2]):
		B[i][j]+=ipt[j]
#C_set
for i in range(k[0]):
	for j in range(k[2]):
		for l in range(k[1]):
			C[i][j]+=A[i][l]*B[l][j]
#print_C
for i in range(k[0]):
	for j in range(k[2]):
		if j==k[2]-1:
			print C[i][j]
		else:
			print C[i][j],

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

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

for c in C:
    print(*c)

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split()) # n = 3, c = 2, l = 3

a_matrix = [list(map(int, input().split())) for row in range(n)] # [[1, 2], [0, 3], [4, 5]]
b_matrix = [list(map(int, input().split())) for row in range(m)] # [[1, 2, 1], [0, 3, 2]]

result_matrix = [[0 for x in range(l)] for y in range(n)] # [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(n):
	for j in range(l):
		for k in range(m):
			result_matrix[i][j] += a_matrix[i][k] * b_matrix[k][j]

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