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

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

# m * l
B = []
for _ in range(m):
    B.append([int(_) for _ in input().split()])


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

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

for C_row in C:
    for i, num_row in enumerate(C_row):
        if i != len(C_row) - 1:
            print(num_row, end=" ")
        else:
            print(num_row, end="")
    print()

        

"""
A = 
[[1, 2], [0, 3], [4, 5]]
 
B = 
[[1, 2, 1],
 [0, 3, 2]]

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

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 == l - 1:
            print(f"{sum}", end="")
        else:
            print(f"{sum} ", end="")
    print()

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]*100 for _ in range(100)]

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

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

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


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

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]
    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 x in range(n)]
b = [list(map(int,input().split())) for x 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 l in c:
    print(*l)

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

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

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

Submission status: Accepted

Solution code:
N, M, L = map(int, input().split())
A = []
B = []

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

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

for n in range(N):
    print(' '.join(map(str, [sum(A[n][m] * B[m][l] for m in range(M)) for l in range(L)])))

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):
    c = []
    for j in range(l):
        matrix = 0
        for k in range(m):
            matrix += a[i][k] * b[k][j]
        c.append(matrix)
    print(*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):
        C[i][j] = str(sum(A[i][k]*B[k][j] for k in range(M)))
for line in C:
    print(*line)

Submission status: Accepted

Solution code:
# coding: utf-8
# 70

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

#print(A,B)

for i in range(n):
    for j in range(l):
        for z in range(m):
            c += A[i][z]*B[z][j]
            #print("j=",j,"z=",z,"m=",m,"l=",l)
        if j<l-1:
            print(c,end=' ')
        else:
            print(c)
        c=0
#print()

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 for _ in range(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_1 in C:
    for i, c2 in enumerate(c_1):
        print(c2, end='')
        if i != l-1:
            print(' ', end='')
    print()

Submission status: Accepted

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

arra = [input().split() for l in range(m)]
arrb = [input().split() for l in range(n)]

for i in range(m):
    retstr = ""
    for j in range(l):
        ans = 0
        for k in range(n):
            ans += int(arra[i][k]) * int(arrb[k][j])
        retstr += str(ans) + " "
    retstrs = retstr.strip()
    print(retstrs)

Submission status: Accepted

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

A =  []
B = []
for r in range(n):
    line = input().split()
    row = [int(x) for x in line]
    A.append(row)

for r in range(m):
    line = input().split()
    row = [int(x) for x in line]
    B.append(row)

# print(A)
# print(B)

C = []
for r in range(n):
    row = []
    for c in range(l):
        s = 0
        for j in range(m):
            s += A[r][j] * B[j][c]
#             print(r, c, j, A[r][j], B[j][c])
        row.append(s)
    C.append(row)

for r in range(n):
    line = ""
    for c in range(l):
        line += str(C[r][c]) + " "
    print(line.strip())

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):
        cc = 0
        for k in range(m):
            cc += a[i][k]*b[k][j]
        c.append(cc)
    print(*c)   #*を付けることによって[]なしで出力できる
    #行列を作ってから出力じゃなくて、1行ごとに出力した

Submission status: Accepted

Solution code:
N, M, L = map(int, input().split())

A = [list(map(int, input().split())) for i in range(N)]  # N*M配列の取得
B = [list(map(int, input().split())) for i in range(M)]  # M*L配列の取得
ANS = [[0] * L for i in range(N)]  # N*L

for x in range(N):
    for y in range(L):
        for z in range(M):
            ANS[x][y] += B[z][y] * A[x][z]

for row in range(N):
    print("%d" % ANS[row][0], end="")
    for col in range(1, L):
        print(" %d" % (ANS[row][col]), end="")
    print()

Submission status: Accepted

Solution code:
n,m,l = map(int,input().split())
a = []
b = []
for i in range(n):
  tmp = list(int(x) for x in input().split())
  a.append(tmp)
  
for j in range(m):
  tmp = list(int(x) for x in input().split())
  b.append(tmp)
  
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 == l-1:
      print(sum,end ="")
    else:
      print(sum,end =" ")
  print()

Submission status: Accepted

Solution code:
#1_7_D
y = []
c = 0
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 t in range(n):
    for u in range(l):
        x = 0

        for s in range(m):
            x += a[t][s] * b[s][u]
        c += 1
        if c%l == 0:
            print(x)
        else:
            print(x,'',end='')

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())))
lst3=[]
for i in range(n):
    for j in range(l):
        c=0
        for k in range(m):
            c+=a[i][k]*b[k][j]
        if j == l-1 :
            print(c)
        else :
            print(c,end=" ")

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 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 line in C:
    print(*line)

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    a, b, c = map(int, input().split())
    
    A = []
    
    for i in range(a):
        ai = list(map(int, input().split()))
        A.append(ai)
    B = []
    for i in range(b):
        bi = list(map(int, input().split()))
        B.append(bi)
    
    temp = 0
    for i in range(a):
        for k in range(c):
            temp = 0
            for m in range(b):
                temp += A[i][m] * B[m][k]
            print(temp, end ="")
            if k == c-1:
                print("")
            else:
                print(" ", end = "")
        
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b,c = [],[],[]
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):
    x = []
    for i2 in range(l):
        y = 0
        for i3 in range(m):
            y += a[i][i3]*b[i3][i2]
        x .append(y)
    print(' '.join(map(str,x)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def run():
    n,m,l=tuple(map(int,input().split()))
    
    A=[]
    
    for i in range(n):
        row_ls=list(map(int,input().split()))
        
        A.append(row_ls)
        
    B=[]
    
    for i in range(m):
        row_ls=list(map(int,input().split()))
        
        B.append(row_ls)
        
    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(f"{C[i][j]} ",end="")
            else:
                print(f"{C[i][j]}")

run()

Submission status: Accepted

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

a = [0 for i in range(n)] 
b = [0 for i in range(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()))

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

Submission status: Accepted

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

arrays1,arrays2=[], []

for i in range(n):
	arrays1.append([int(x) for x in input().split()])

for j in range(m):
	arrays2.append([int(x) for x in input().split()])


for a in range(len(arrays1)):	
	for b in range(len(arrays2[0])):
		sss=0
		for c in range(len(arrays1[0])):
			sss+=arrays1[a][c]*arrays2[c][b]
		print(f"{sss}",end="")
		if b != len(arrays2[0])-1:
			print(" ",end="")
	print()

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

Submission status: Accepted

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

Q1 = []
Q2 = []
for x in range(n):
    Q1.append(list(map(int, input().split())))

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

Ans = []
for x in range(n):
    Ans.append([])
    for y in range(l):
        ans = 0
        for z in range(m):
            ans += Q1[x][z]*Q2[z][y]
        Ans[x].append(ans)
 
for x in range(n):   
    print(*Ans[x], end="\n")

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

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

Submission status: Accepted

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

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

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

C=[]
for k in range(n):
    line=[]
    for s in range(l):
        c=0
        for t in range(m):
            c+=a[k][t]*b[t][s]
        line.append(c)
    C.append(line)

for line in C:
    print(*line)

Submission status: Accepted

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

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


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

for q in range(n):
    print('%d'%a[q][0],end='')
    for p in range(1,l):
        print(' %d'%(a[q][p]),end='')
    print('')

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!


n, m, l = 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)]

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

#print(A)
#print(B)

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

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

for i in range(n):
   for k in range(l):
      print(C[i][k], end = "")
      if k < l - 1:
         print(" ", end = "")
   #if i < n - 1:
   print("")

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

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

Submission status: 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 an in range(n):
    ar = list(map(int, input().split()))
    for am in range(m):
        A[an][am] = ar[am]

for bm in range(m):
    br = list(map(int, input().split()))
    for bl in range(l):
        B[bm][bl] = br[bl]

for nnn in range(n):
    for lll in range(l):
        for mmm in range(m):
            C[nnn][lll] += A[nnn][mmm] * B[mmm][lll]

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

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 ni in range(n):
  for li in range(l):
    for mi in range(m):
      ANS[ni][li] += A[ni][mi]*B[mi][li]
    if li!=l-1:
      print(ANS[ni][li],end=' ')
    else:
      print(ANS[ni][li])

Submission status: Accepted

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

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

c = []
for i in range(n):
    for j in range(l):
        ci = 0
        for k in range(m):
            ci += a[i][k] * b[k][j]
        c.append(ci)
s = ''
for i in range(1, len(c)+ 1):
    s += str(c[i-1]) + ' '
    if i % l == 0:
        s = s[:-1]
        print(s)
        s = ''

Submission status: Accepted

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

for i in range(n):
    C.append([])

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

Submission status: Accepted

Solution code:
def get_matrix(line):
    matrix = []
    for _ in range(line):
        matrix.append(list(map(int, input().split())))
    return matrix


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

matrix_c = []
for i in range(n):
    line = []
    for j in range(l):
        tmp = 0
        for k in range(m):
            tmp += matrix_a[i][k] * matrix_b[k][j]
        line.append(tmp)
    matrix_c.append(line)
for i in range(n):
    print(' '.join(list(map(str, matrix_c[i]))))

Submission status: Accepted

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

table1 = [[0 for j in range(m)]for i in range(n)]
table2 = [[0 for k in range(l)]for j in range(m)]
table3 = [[0 for k in range(l)]for i in range(n)]

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

    for j in range(m):
        table1[i][j] = a[j]
#print(table1)

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

    for k in range(l):
        table2[j][k] = b[k]
#print(table2)

for i in range(n):
    for k in range(l):
        for j in range(m):
            table3[i][k] += table1[i][j]*table2[j][k]
        if k == l-1:
            print(table3[i][k])
        else:
            print(table3[i][k],"",end="")

Submission status: Accepted

Solution code:
matrix_a, matrix_b = [], []
inp, hid, out = map(int, input().split())
for _ in range(inp):
  matrix_a.append(list(map(int, input().split() )))

for _ in range(hid):
  matrix_b.append(list(map(int, input().split() )))

mul = [[0 for _ in range(out)] for _ in range(inp)]
for i in range(inp):
    for j in range(out):
        for k in range(hid):
            mul[i][j] += matrix_a[i][k] * matrix_b[k][j]

for i in range(inp):
  strings = ''
  for j in range(out):
    strings += str(mul[i][j]) + ' '
  print(strings[:-1])

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):
    list = input().split()
    for j in range(m):
        a[i][j] = int(list[j])
for i in range(m):
    list = input().split()
    for j in range(l):
        b[i][j] = int(list[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]
        print(c[i][j], end='')
        if j < l-1:
            print(' ', end='')
    print()

Submission status: Accepted

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

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

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

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

for i in range(n):
    Ci = C[i]
    for j in range(l):
        if j<l-1:
            print(Ci[j],end=' ')
        if j==l-1:
            print(Ci[j])

Submission status: Accepted

Solution code:
N,M,L = map(int,input().split())

A = [list(map(int,input().split())) for i in range(N)] #N*M配列の取得
B = [list(map(int,input().split())) for i in range(M)] #M*L配列の取得
ANS = [[0]*L for i in range(N)] #N*L


for x in range(N):
    for y in range(L):
        for z in range(M):
            ANS[x][y] += B[z][y]*A[x][z]

for row in range(N):
    print("%d"%ANS[row][0],end = "")
    for col in range(1,L):
        print(" %d"%(ANS[row][col]),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([int(s) for s in input().split()])
for i in range(m):
    B.append([int(t) for t in 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 range(n):
    print(' '.join(C[i]))

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

nm = []
ml = []
cij = []

for i in range(n):
    nm.append(list(map(int,input().split())))
    
for j in range(m):
    ml.append(list(map(int, input().split())))

for i in range(n):
    tmp = []
    for j in range(l):
        sum = 0
        for k in range(m):
            sum += nm[i][k]*ml[k][j]
        tmp.append(sum)
    cij.append(tmp)


for p in cij:
    print(*p)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

matrixA = []
matrixB = []
matrixANS =[]

for i in range(n):
    matrixA.append([int(x) for x in input().split()])

for j in range(m):
    matrixB.append([int(x) for x in input().split()])

for row_A in matrixA:
    numlist = []
    for j in range(l):
        sum = 0
        for k in range(m):
            sum += row_A[k] * matrixB[k][j]
        numlist.append(sum)
    matrixANS.append(numlist)

for ans in matrixANS:
    print(" ".join(map(str,ans)))

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
a = [0]*n
b = [0]*m
c = [[0]*l for i in range(n)]
for row in range(n):
    a[row] = list(map(int, input().split()))
for row in range(m):
    b[row] = 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())
mat_A = [list(map(int, input().split())) for _ in range(n)]
mat_B = [list(map(int, input().split())) for _ in range(m)]


for row in mat_A:
    result_row = []
    for col in zip(*tuple(mat_B)):
        c = 0
        for pair in zip(row, col):
            c += pair[0] * pair[1]
        result_row.append(c)
    print(" ".join(map(str, result_row)))

Submission status: Accepted

Solution code:
n, m, l = [int(arg) for arg in input().split()]
a = [[int(arg) for arg in input().split()] for _ in range(n)]
b = [[int(arg) for arg in input().split()] for _ in range(m)]
c = [[0] * l for _ 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(' '.join([str(j) for j 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 i in range(n)]
B=[[int(x) for x in 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):
        sum=0
        for k in range(m):
            sum+=A[i][k]*B[k][j]
        C[i][j]=sum
for i in range(n):
    for j in range(l):
        if j!=l-1:
            print(C[i][j], end=" ")
        else:
            print(C[i][j])

Submission status: Accepted

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

l1 = [list(map(int, input().split())) for i in range(n)]
l2 = [list(map(int, input().split())) for i in range(m)]
result = []

for i in range(n):
    tmp = l1[i]
    _ = []
    for j in range(l):
        ans = 0
        for k in range(m):
            ans += (tmp[k] * l2[k][j])
        _ += [ans]
    result += [_]

for i in result:
    print(" ".join([str(x) for x in i]))

Submission status: Accepted

Solution code:
N, M, L = list(map(int, input().split()))
NMtable = [[] for i in range(N)]
MLtable = [[] for i in range(M)]

for i in range(N):
    nums = list(map(int, input().split()))
    NMtable[i] = nums

for i in range(M):
    nums = list(map(int, input().split()))
    MLtable[i] = nums
    
for n in range(N):
    for l in range(L):
        total = 0
        for m in range(M):
             total += NMtable[n][m] * MLtable[m][l]
        if l > 0: print(" ", end="")
        print(f"{total}", end="")
    print()

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)]
i = 0
while i < n:
    a[i] = list(map(int,input().split()))
    i+=1

i = 0
while i < m:
    b[i] = list(map(int,input().split()))
    i+=1

for i in range(n):
    for j in range(l):
        res = 0
        for k in range(m):
            res = res + a[i][k] * b[k][j]
        if j == l-1:
            print(f"{res}",end="")
        else:
            print(f"{res} ",end="")
        #print(f"{a[0][0] * b[0][j] + a[0][1] * b[1][j]} ",end="")
    print()

Submission status: Accepted

Solution code:
def matrix_input(a,b):

    a = int(a)
    b = int(b)

    Data = []

    while True:
        if a == 0:
            break
        temp = input().split()
        Data.append(list(map(int,temp)))
        a -= 1

    return Data

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

n = int(n)
m = int(m)
l = int(l)

Data1 = matrix_input(n,m)
Data2 = matrix_input(m,l)

# output = [[0]*l for a in range(n)]
output = []

temp = 0
templist = []
for a in Data1:
    for i in range(l):
        count = 0
        for b in a:
            temp += b * Data2[count][i]
            count += 1
        templist.append(temp)
        if len(templist) == l:
            output.append(templist)
            templist = []
        temp = 0

for a in output:
    b = map(str,a)
    print(' '.join(b))

Submission status: Accepted

Solution code:
x=[]
y=[]
n,m,l=map(int,input().split())
r=[[0]*l for n in range(n)]
for i in range(n):
    x.append(list(map(int,input().split())))
for i in range(m):
    y.append(list(map(int,input().split())))
for i in range(n):
    for j in range(l):
        s=0
        for k in range(m):
            s+=x[i][k]*y[k][j]
        r[i][j]=s
for n in range(n):
    print(' '.join(map(str,r[n])))

Submission status: Accepted

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