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

matrix1 = []
matrix2 = []

for n in range(N):
    matrix1.append(list(map(int, input().split())))
for l in range(M):
    matrix2.append(list(map(int, input().split())))


res = []
for n in range(N):
    larr = []
    for l in range(L):
        tmp = 0
        for m1,m2 in zip(matrix1[n], [matrix2[m][l] for m in range(M)]):
            tmp += m1*m2
  #      print(larr)
        larr.append(tmp)
 #       print(larr)
    res.append(larr)

for n in range(N):
    print(*res[n],sep=" ")

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
n_m_matrix = [list(map(int, input().split())) for _ in range(n)]
m_l_matrix = [list(map(int, input().split())) for _ in range(m)]
result = []

for i in range(n):
    tmp_list = []
    for k in range(l):
        tmp = 0
        for j in range(m):
            tmp += n_m_matrix[i][j] * m_l_matrix[j][k]
        tmp_list.append(tmp)
    result.append(tmp_list)

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

Submission status: Accepted

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

for i in range(0, len(c)):
	for j in range(0, len(c[i])):
		if j != len(c[i]) - 1:
			print('{0} '.format(c[i][j]), end='')
		else:
			print(c[i][j])
# print(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 = []
for i in range(n):
    line = []
    for j in range(l):
        c = 0
        for k in range(m):
            c += A[i][k]*B[k][j]
        line.append(c)
    C.append(line)
    
for line in C:
    print(*line)

Submission status: Accepted

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

A = [0]*n
B = [0]*m

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

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

C = [0]*n

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

for i in range(n):
    temp = []
    for j in range(l):
        temp.append(str(C[i][j]))
    line = " ".join(temp)
    print(line)

Submission status: Accepted

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

Amatrix = []
Bmatrix = []

for ia in range(n):
    Amatrix.append(list(map(int, input().split())))

for ib in range(m):
    Bmatrix.append(list(map(int, input().split())))

Cmatrix = [[0 for ic in range(l)] for ie in range(n)]

for ig in range(n):
    for ih in range(l):
        SUM = 0
        for ii in range(m):
            SUM += Amatrix[ig][ii] *  Bmatrix[ii][ih]
        Cmatrix[ig][ih] = str(SUM)
        
for ij in range(n):
    print(' '.join(Cmatrix[ij]),end='\n')

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 i in range(m):
    b.append(list(map(int, input().split())))

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

Submission status: Accepted

Solution code:
n,m,l = map(int,input().split())
A=[list(map(int,input().split()))for _ in[0]*n]
B=[list(map(int,input().split()))for _ in[0]*m]
C=[[sum([x[i]*y[i] for i in range(m)])for y in zip(*B)]for x in A]
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)]
BT = [list(x) for x in zip(*B)]

for a in A:
    c = []
    for b in BT:
        c.append(sum(x*y for x,y in zip(a,b)))
    print(*c)

Submission status: Accepted

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

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

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

    C.append(tmp2)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  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 = list()

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

  for c_row in C:
    print(*c_row)

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
matrix1 = []
matrix2 = []
for i in range(n+m):
  list_ = list(map(int, input().split()))
  if i+1 <= n:
    matrix1.append(list_)
  else:
    matrix2.append(list_)

for j in range(n):
  list_ = []
  for k in range(l):
    sum_ = 0
    for mm in range(m):
      sum_ += matrix1[j][mm] * matrix2[mm][k]
    list_.append(sum_)
  print(' '.join(list(map(str, list_))))

Submission status: Accepted

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

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

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

ele = 0

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

for i in range(n):
    print(*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)]
C = []
for i in range(n):
    c_row = []
    for q in range(l):
        c = 0
        for j in range(m):
            c = c + A[i][j] * B[j][q]
        c_row.append(c)
    C.append(c_row)
def printmatrix(rc):
    for i in range(len(rc)):
        for j in range(len(rc[0])):
            print(rc[i][j],end = "")
            if j != len(rc[0])-1:
                print(" ",end = "")
            else:
                print("")
printmatrix(C)

Submission status: Accepted

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

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

ml=[]
for j in range(m):
    ml_value = list(map(int,input().split()))
    ml.append(ml_value)

C = [[0 for row in range(l)] for column in range(n)] 
for i in range(n):
    for j in range(m):
        for k in range(l):
            C[i][k] += nm[i][j]*ml[j][k]

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

Submission status: Accepted

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

A = []
B = []

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

C = []
L = []
s = 0

for i in range(l) :
    for j in range(n) :
        for k in range(m) :
            s += A[j][k] * B[k][i]
        
        L.append(s)
        s = 0
    
    C.append(L[i * n : i * n + n])
        
for i in range(n) :
    for j in range(l) :
        if j == l - 1 :
            print(C[j][i])
        else :
            print(C[j][i], end = " ")

Submission status: Accepted

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

matrixA = []
matrixB = []
matrixC = [[0 for i in range(l)] for j in range(n)]

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

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

for index_a in range(len(matrixA)):
    for index_b in range(len(matrixB[0])):
        for index_c in range(len(matrixB)):
            matrixC[index_a][index_b] += matrixA[index_a][index_c] * matrixB[index_c][index_b]

for i in matrixC:
    print(*i, sep=" ")

Submission status: Accepted

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

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

vec_C = [[0]*l for i in range(n)]
    
for i in range(n):
    for j in range(l):
        for k in range(m):
            vec_C[i][j] += vec_A[i][k] * vec_B[k][j]

for row in range(n):
    print('{}'.format(vec_C[row][0]), end='')
    for col in range(1, l):
        print(' {}'.format(vec_C[row][col]), end='')
    print()

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
ar = []
br = []
cr = [[0 for _ in range(l)] for _ in range(n)]

i = 0
while n > i:
    ar.append([int(s) for s in input().split()])
    i += 1

i = 0
while m > i:
    br.append([int(s) for s in input().split()])
    i += 1

i, j , k= 0, 0, 0
while n > i:
    while l > j:
        while m > k:
            cr[i][j] += (ar[i][k] * br[k][j])
            k += 1
        k = 0
        j += 1
    j = 0
    i += 1

i, j = 0, 0
while n > i:
    while l > j:
        if l != j + 1:
            print("{} ".format(cr[i][j]), end="")
        elif l == j + 1:
            print(cr[i][j])
        j += 1
    j = 0
    i += 1

Submission status: Accepted

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

x = 0
A = [list(map(int,input().split(" "))) for i in range(n)]
B = [list(map(int,input().split(" "))) for j in range(m)]
AB = [[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):
                x += A[i][k] * B[k][j]
                AB[i][j] = x
            x = 0

for a in AB:
    print(*a)

Submission status: Accepted

Solution code:

A = []
B = []
ans = []
n,m,l = map(int, input().split())
for i in range(n):
    elem = list(map(int,input().split()))
    A.append(elem)
for i in range(m):
    elem = list(map(int, input().split()))
    B.append(elem)

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

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

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

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

#print(ans)

for row in ans:
    for i,num in enumerate(row):
        if(i):
            print("",end=" ")
        print(num,end="")
    print()

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

M=[]
for i in range(n):
    line=[]
    for j in range(l):
        sum=0
        for k in range(m):
            sum+=A[i][k]*B[k][j]
        line.append(sum)
    M.append(line)
for a in range(n):
    print(*M[a])

Submission status: Accepted

Solution code:
a,b,c,=map(int,input().split())
lis_1=[list(map(int,input().split())) for i in range(a)]
lis_2=[list(map(int,input().split())) for j in range(b)]
ans=[[0 for k in range(c)] for l in range(a)]
d=0
for i in range(a):#ansの行の変化
    for l in range(c):#ansの列をずらす
        for k in range(b):#lis_1の列をずらす
            d+=lis_1[i][k]*lis_2[k][l]
        ans[i][l]=d
        d=0
for z in range(a):
    for x in range(c-1):
        print(ans[z][x],end=" ")
    print(ans[z][c-1])

Submission status: Accepted

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

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 row in C:
    print(' '.join(map(str, row)))

Submission status: Accepted

Solution code:
rows = list(map(int,input().split()))
a = list()
b = list()
for i in range(rows[0]):
    a.append(list(map(int,input().split())))

for i in range(rows[1]):
    b.append(list(map(int,input().split())))

c = [[0]*rows[2] for i in range(rows[0])]
for i in range(rows[0]):
    for j in range(rows[2]):
        for k in range(rows[1]):
            c[i][j] += a[i][k]*b[k][j]


for i in range(rows[0]):
    print(*c[i])

Submission status: Accepted

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

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


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

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 p in range(n):
    print(*C[p])

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 i in range(m):
  b.append(list(map(int,input().split())))

d = [[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):
      d[i][j] += a[i][k]*b[k][j]

for i in range(n):
  for j in range(l):
    print(d[i][j] , end="")
    if j == l - 1:
      print()
    else:
      print(" ",end="")

Submission status: Accepted

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

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

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

for x in range(n):
  result = []
  for y in range(l):
    tmp = 0
    for z in range(m):
      tmp += a[z + x * m] * b[l*z + y]
    result.append(tmp)
  print(" ".join(map(str, result)))

Submission status: Accepted

Solution code:
base_num = input()
unit = base_num.split(' ')
vec_n_max = int(unit[0])
vec_m_max = int(unit[1])
vec_o_max = int(unit[2])
end_num = 0

input_list = []
while True:
    base_suit = input()
    input_list.append(base_suit)

    end_num += 1
    if (vec_n_max + vec_m_max) == end_num:
        break

matrix_a = []
matrix_b = []
for i, r in enumerate(input_list):
    if i < vec_n_max: 
        row = r.split(' ')
        matrix_a.append([int(x) for x in row])
    else:
        row = r.split(' ')
        matrix_b.append([int(x) for x in row])

for i in range(vec_n_max):
    for j in range(vec_o_max):
        c = 0
        for k in range(vec_m_max):
            c += matrix_a[i][k] * matrix_b[k][j]
        print('{}'.format(c),end='')
        if j != vec_o_max-1:
            print(' ',end='')
    print()

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
A = [[int(a) for a in input().split()] for _ in range(n)]
B = [[int(b) for b in input().split()] for _ in range(m)]
C = [[0] * l for _ 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 c in C:
    print(*c)

Submission status: Accepted

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

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_table = [[0 for i in range(m)] for j in range(n)]
B_table = [[0 for i in range(l)] for j in range(m)]
C_table = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    Col = list(map(int, input().split()))
    A_table[i] = Col
for i in range(m):
    Col = list(map(int, input().split()))
    B_table[i] = Col


for i in range(l):
    for j in range(n):
        ele = 0
        for t in range(m):
            ele += A_table[j][t]*B_table[t][i]
        C_table[j][i] = ele

for i in range(n):
    for j in range(l):
        if j == l-1:
            print(C_table[i][j], end = "")
        else:
            print(C_table[i][j], end = " ")
    print()

Submission status: Accepted

Solution code:
# n, m, l = 3, 2, 3
# matrixA = [[1, 2],[0, 3],[4, 5]]
# matrixB = [[1, 2, 1],[0, 3, 2]]

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 j in range(m)]

# Output用の行列を初期作成
ans = [[0 for i in range(l)] for j in range(n)]
#
for N in range(n):
    for L in range(l):
        sum = 0
        for M in range(m):
            sum += matrixA[N][M] * matrixB[M][L]
        ans[N][L] = sum
    print(*ans[N])

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

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

C_str = [[str(x) for x in y] for y in C]

for i in range(n):
    li = C_str[i]
    print(" ".join(li))

Submission status: Accepted

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

A =[]
B = []
ans =[]

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

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

for x in range(n):
    L = []
    for y in range(l):
        a = 0
        for z in range(m):
            a += A[x][z]*B[z][y]
        L.append(str(a))

    ans.append(L)

for a in ans:
    print(" ".join(a))

Submission status: Accepted

Solution code:
import functools
import operator


if __name__ == "__main__":
    n, m, l = list(map(int, input().split()))

    inputs = []

    for _ in range(n + m):
        inputs.append(input())

    matrix_a = list(map(
        lambda input: list(map(int, input.split())),
        inputs[:n]
    ))
    matrix_b = list(map(
        lambda input: list(map(int, input.split())),
        inputs[n:n + m]
    ))

    matrix_c = []

    for row_a in matrix_a:
        row_c = []

        for col_b in list(zip(*matrix_b)):
            elem_c = functools.reduce(
                lambda acc, elem: acc + elem,
                map(operator.mul, row_a, col_b),
                0
            )

            row_c.append(elem_c)

        matrix_c.append(row_c)

    for row_c in matrix_c:
        print(' '.join(map(str, row_c)))

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

for i in c:
  print(*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())))

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

for line in ans:
    print(' '.join(map(str, line)))

Submission status: Accepted

Solution code:
n,m,l = map(int,input().split())
tbl = [[0 for i in range(l)] for j in range(n)]
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):
        sum = 0
        for k in range(m):
            sum += a[i][k]*b[k][j]
        tbl[i][j] = sum
for i in range(n):
    for j in range(l):
        if j != l-1:
            print(tbl[i][j], end=' ')
        else:
            print(tbl[i][j])

Submission status: Accepted

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

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):
        sum = 0
        for k in range(m):
            sum += A[i][k] * B[k][j]
        row.append(sum)
    C.append(row)

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

Submission status: Accepted

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

mtrx1 = [list(map(int, input().split())) for i in range(n)]
mtrx2 = [list(map(int, input().split())) for i in range(m)]

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

for i in range(n):
    for j in range(l):
        for k in range(m):
            mtrx_ans[i][j] +=  mtrx1[i][k] * mtrx2[k][j]

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

Submission status: Accepted

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

A = []
B = []

for i in range(n):
    A.append(input().split())
for i in range(m):
    B.append(input().split())
answer = []
for n_i in range(n):
    for l_i in range(l):
        X = 0
        for m_i in range(m):
            X += int(A[n_i][m_i]) * int(B[m_i][l_i])
        answer.append(X)
index = 0
Y = l
for i in range(n):
    print(*answer[index:l])
    index += Y
    l += Y

Submission status: Accepted

Solution code:
n,m,l=input().split()
n,m,l=[int(n),int(m),int(l)]
A=[0]*n
B=[0]*m
for i in range(n):
    A[i]=list(map(int, input().split()))
for i in range(m):
    B[i]=list(map(int, input().split()))
C=[[0]*l for i 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):
    results=" ".join([str(c) for c in C[i]])
    print(results)

Submission status: Accepted

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

A = [[int(i) for i in input().split()] for _ in range(n)]
B = [[int(i) for i in 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 else '\n')

Submission status: Accepted

Solution code:
n, m, l = map(int, 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 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):
    print(" ".join(map(str, C[i])))

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
A = [[*map(int, input().split())] for i in range(n)]
B = [[*map(int, input().split())] for i in range(m)]
for i in range(n):
    for j in range(l):
        sum = 0
        for k in range(m):
            sum += A[i][k]*B[k][j]
        if j > 0:
            print(end = ' ')
        print(sum, end = '')
    print()

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:
n, m, l = map(int, input().split())
a_list = []
b_list = []
for i in range(n):
	a_list.append(list(map(int, input().split())))
for i in range(m):
	b_list.append(list(map(int, input().split())))
c_list = [[0 for i in range(l)] for i in range(n)]
for i in range(n):
	for j in range(l):
		for k in range(m):
			c_list[i][j] += a_list[i][k] * b_list[k][j]
for c in c_list:
	print(' '.join(list(map(str, c))))

Submission status: Accepted

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

ans = []
for i in range(n):
    row_lst = []
    for j in range(l):
        tmp_k = 0
        for k in range(m):
            tmp_k += A[i][k] * B[k][j]
        row_lst.append(tmp_k)
    ans.append(row_lst)
for row in ans:
    print(*row)

Submission status: Accepted

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)]
ans = [[0]*l for i in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            ans[i][j] += a[i][k]*b[k][j]
print("\n".join(" ".join(map(str, i)) for i in ans))

Submission status: Accepted

Solution code:
def main():
    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):
        C = []
        for j in range(l):
            ij = 0
            for k in range(m):
                ij += A[i][k]*B[k][j]
            C.append(ij)
        print (' '.join(map(str,C)))

if __name__ == '__main__':
    main()

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 i in range(m):
    b.append(list(map(int,input().split())))

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

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

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

Submission status: Accepted

Solution code:
n, m, l = tuple(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)]
matrixC = [[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):
            matrixC[i][j] += matrixA[i][k] * matrixB[k][j]

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

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 i 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]
    print(*C[i])

Submission status: Accepted

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

A = []
B = []
C = []
inner = []
x = 0

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

for i in C:
    print(" ".join(map(str, 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 i in range(m):
    b.append(list(map(int, input().split())))
for i in range(n):
    for j in range(l):
        ans = 0
        for k in range(m):
            ans += a[i][k]*b[k][j]
        if j == l-1:
            print(f'{ans}', end='')
        else:  
            print(f'{ans} ', end='')
    print()

Submission status: Accepted

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