Problem:


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

Matrix Multiplication

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

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

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

Input

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

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

Output

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

Constraints

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

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

Sample Input

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

Sample Output

1 8 5
0 9 6
4 23 14

Note

      解説      

	



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


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

Submission status: Accepted

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

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

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):
    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):
            save=0
            for k in range(m):
                save+=A[i][k]*B[k][j]
            C[i][j]=save
            if j==0:
                print(C[i][j],end="")
            else:
                print("",C[i][j],end="")
        print()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(m):  #inputB
    line = input().split()
    for j in range(l):
        B[i][j] = int(line[j])

# 行列の積計算
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):  #outputC
    for j in range(l):
        if j != l - 1:
            print("%d " %C[i][j], end="")
        else:
            print(C[i][j])

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):
        c = 0
        print("{}{}".format(' ' if j else '', sum(A[i][k] * B[k][j] for k in range(m))), end='')
    print()

Submission status: Accepted

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

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

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

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

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


for _n in range(n):
    for _l in range(l):
        print(c[_n][_l], end='')
        if _l == l-1:
            print('')
        else:
            print(' ',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 for i in range(l)]for j in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j]+=A[i][k]*B[k][j]

for i in c:
    print(*i)

Submission status: Accepted

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

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

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

for i in range(n):
    row = []
    for j in range(l):
        tmp = 0
        for k in range(m):
            tmp += A[i][k] * B[k][j]
        row.append(str(tmp))
    print("{}".format(' '.join(row)))

Submission status: Accepted

Solution code:
N,M,L = map(int,input().split())
anm=[[0]*M for _ in range(N)]
bml=[[0]*L for _ in range(M)]
cnl=[[0]*L for _ in range(N)]


for n in range(N):
  data = list(map(int,input().split()))
  for m in range(M):
    anm[n][m] = data[m]

for m in range(M):
  data = list(map(int,input().split()))
  for l in range(L):
    bml[m][l] = data[l]

for n in range(N):
  for l in range(L):
    for m in range(M):
      cnl[n][l] += anm[n][m]*bml[m][l]

for n in range(N):
  for l in range(L):
    if l==L-1:
      print("{:d}".format(cnl[n][l]))
    else:
      print("{:d}".format(cnl[n][l]),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 = []
[c.append([0] * l) for _ in range(n)]

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

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

Submission status: Accepted

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

array_a=[]
array_b=[]
array_c=[[0 for i in range(l)] for j in range(n)]

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

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


for i in range(n):
	for j in range(m):
		for k in range(l):
			array_c[i][k]+=array_a[i][j] * array_b[j][k]
	print(" ".join(map(str,array_c[i])))

Submission status: Accepted

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

A = list()
B = list()
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):
        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("%d"%C[i][j],end=" ")
#     print("")

for line in C:
    print(*line)

Submission status: Accepted

Solution code:
#ITP1_7_D
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):
  D=list(map(int,input().split()))
  for j in range(m):
    A[i][j]=D[j]
for i in range(m):
  E=list(map(int,input().split()))
  for j in range(l):
    B[i][j]=E[j]

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

Submission status: Accepted

Solution code:
import sys
  
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
  
  
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 = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for j 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] = 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 = []
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):
        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:
L=input().split( )

n=int(L[0])
m=int(L[1])
l=int(L[2])

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)]
i=0
j=0

while i<n:
    StrCollum = input().split( )
    for k in range(m):
        A[i][k] = int(StrCollum[k])
    i+=1

while j<m:
    StrCollum = input().split( )
    for k in range(l):
        B[j][k] = int(StrCollum[k])
    j+=1

for a in range(n):
    for b in range(l):
        sum=0
        for k in range(m):
            sum = sum + A[a][k]*B[k][b]
            C[a][b]=sum
        #C[a][b]のインデントの位置がおかしかった。ここだとb=l-1の時しかC[][]が更新されない。
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())

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())))
  
BT = list(map(list, zip(*B)))


C =[[0 for k 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 c in C:
    for i in range(len(c)):
        if i+1 == len(c):
            print(c[i])
        else:
            print(c[i], end=" ")

Submission status: Accepted

Solution code:
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)


def main():
    a,b,c=map(int,input().split())
    g=[list(map(int,input().split()))for i in range(a)]
    h=[list(map(int,input().split()))for i in range(b)]
    for i in zip(*[[sum(s*t for s,t in zip(g[r],[h[j][i]for j in range(b)]))for r in range(a)]for i in range(c)]):
        print(*i)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

matrix_A = []
matrix_B = []
matrix_C = [[0 for i in range(l)] for j in range(n)]

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

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

# CALC, OUTPUT
for cnt_n in range(n):
    for cnt_l in range(l):

        for cnt_m in range(m):

            matrix_C[cnt_n][cnt_l] += matrix_A[cnt_n][cnt_m] * matrix_B[cnt_m][cnt_l]

# OUTPUT
for cnt_n in range(0, n):
    print(f"{matrix_C[cnt_n][0]}", end="")
    
    for cnt_l in range(1, l):
        print(f" {matrix_C[cnt_n][cnt_l]}", 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)]
for i in range(n):
    print(' '.join(str(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 = [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 = []  #i行目のlist
  for j in range(l) :
    c = 0
    for k in range(m) :
      c += A[i][k] * B[k][j]
      
    C.append(str(c))
  print(" ".join(C))

Submission status: Accepted

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

# 列=n
for i in range(n):
    A.append(list(map(int, input().split())))
# 列=m
for i in range(m):
    B.append(list(map(int, input().split())))
# 列=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 line in C:
    print(*line)

Submission status: Accepted

Solution code:
def ext_row(i, matrix):
    return matrix[i]


def ext_col(j, matrix):
    return [row[j] for row in matrix]


def inner_prod(va, vb):
    return sum([a * b for a, b in zip(va, vb)])


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

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

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

ans = [[0] * l for _ in range(n)]
for i in range(n):
    for j in range(l):
        ans[i][j] = inner_prod(ext_row(i, A), ext_col(j, B))
for row in ans:
    print(' '.join([str(i) for i in row]))

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 i in range(N):
    for j in range(L):
        for k in range(M):
            ANS[i][j] += A[i][k] * B[k][j]

for i in range(N):
    print("%d" % ANS[i][0], end="")
    for j in range(1, L):
        print(" %d" % (ANS[i][j]), 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)]
 
for i in range(n) :
  C = []  #i行目のlist
  for j in range(l) :
    c = 0
    for k in range(m) :
      c += A[i][k] * B[k][j]
     
    C.append(str(c))
  print(" ".join(C))

Submission status: Accepted

Solution code:
n,m,l=map(int,input().split())
R=list()
L=list()
M=list()
K=list()
N=list()
O=list()
P=list()
sum=0
for a in range(n):
    R=list(map(int,input().split()))
    L.append(R)
for h in range(m):
    K=list(map(int,input().split()))
    N.append(K)
for i in range(l):
    for b in range(n):
        for c in range(m):
            sum+=L[b][c]*N[c][i]
        O.append(sum)
        sum=0
    P.append(O)
    O=list()
for y in range(n):
    for j in range(l-1):
        print(P[j][y],end=" ")
    print(P[l-1][y])

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    # test()
    res = []
    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]
            res.append(s)

    for i in range(len(res)):
        if (i % l) == l-1:
            print(res[i])
        else: 
            print(res[i], end=" ")

Submission status: Accepted

Solution code:
n,m,l = [int(x) for x in input().split()]
       
a = [[0 for j in range(m)] for i in range(n)] #n行,m列
b = [[0 for k in range(l)] for j in range(m)]


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

c = [[0 for j in range(l)] for i 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([str(x) for x in c[i]]))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	n, m, l = map(int, input().split())
	a,b,c = [], [], []
	for i in range(n):
		a.append([int(s) for s in input().split()])
		c.append([0 for k in range(l)])
	for i in range(m):
		b.append([int(s) for s in input().split()])
	
	for i in range(n):
		for k in range(l):
			ans = 0
			for j in range(m):
				ans += a[i][j] * b[j][k]	
			c[i][k] = ans
	
	for i in range(n):
		print("%d" % (c[i][0]), end= "")
		for k in range(1,l):
			print(" %d" % (c[i][k]), end="")
		print()

Submission status: Accepted

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

# matrixA
mtxA = []
for i in range(n):
    list_tmp = list(map(int, input().split()))
    mtxA.append(list_tmp)

# matrixB
mtxB = []
for i in range(m):
    list_tmp = list(map(int, input().split()))
    mtxB.append(list_tmp)

# initialize C
mtxC = [[0 for i in range(l)] for i in range(n)]

# compute mtxA x mtxB
for n_tmp in range(n):
    for l_tmp in range(l):
        for m_tmp in range(m):
            mtxC[n_tmp][l_tmp] += mtxA[n_tmp][m_tmp] * mtxB[m_tmp][l_tmp]

# output
for n_tmp in range(n):
    for l_tmp in range(l):
        print(mtxC[n_tmp][l_tmp], end='')
        if l_tmp < l-1:
            print(' ', end='')
    print('')

Submission status: Accepted

Solution code:
v = lambda: list(map(int,input().split()))
n,m,l = v()
a = [v() for i in range(n)]
b = [v() for i in range(m)]
t = [[b[i][j] for i in range(m)] for j in range(l)]
for i in range(n):
	print(*(sum(x*y for x,y in zip(a[i], t[j])) for j in range(l)))

Submission status: Accepted

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

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

for i in range(n):
    for j in range(l):
        ans = 0
        for k in range(m):
            ans += A[i][k] * B[k][j]
        print(ans, end='')
        if j == l-1:
            print()
        else:
            print(' ', 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)]
s = [[0] * l for i in range(n)]

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

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

Submission status: Accepted

Solution code:
sizes = list(map(int, input().split()))
a, b, c = [], [], []
for i in range(sizes[0]):
    a.append(list(map(int, input().split())))
for i in range(sizes[1]):
    b.append(list(map(int, input().split())))
for i in range(sizes[0]):
    c.append([])
    for j in range(sizes[2]):
        t = 0
        for k in range(sizes[1]):
            t += a[i][k] * b[k][j]
        c[i].append(t)
for i in range(sizes[0]):
    for j in range(sizes[2]):
        if j < sizes[2]-1:
            print(c[i][j], end = ' ')
        else:
            print(c[i][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配列の取得
C = [[] for c in range(N)];
for n in range(N):
    for l in range(L):
        value = 0;
        for m in range(M):
            value = value + A[n][m] * B[m][l];
        C[n].append(value);
        if l == L-1:
            print(C[n][l], end="");
        else:
            print(C[n][l], end=" ");
    print();
'''
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=[list(map(int, input().split())) for a in range(n)]
b=[list(map(int, input().split())) for B in range(m)]

x = [[sum([j*k for j,k in zip(h,i)]) for i in zip(*b)] for h in A]

for ans in x:
    print(*ans)

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):
    S1 = input().strip().split()
    S1 = [int(s) for s in S1]
    for j in range(m):
        A[i][j] = S1[j]
        #if j == m-1:
        #    print(S1[j])
        #else:
        #    print(S1[j],end=' ')
    
    
for i in range(m):
    S2 = input().strip().split()
    S2 = [int(s) for s in S2]
    for j in range(l):
        B[i][j] = S2[j]
        #if j == m-1:
        #    print(S2[j])
        #else:
        #    print(S2[j],end=' ')    

for x in range(n):
    for y in range(l):
        for z in range(m):
            C[x][y] += A[x][z]*B[z][y]
        if y == l-1:
            print(C[x][y])
        else:
            print(C[x][y],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]*l for i in range(n)]
 
 
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 = []
for i in range(n):
    row1 = list(map(int,input().split()))
    a.append(row1)
#print(a)

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

for i in range(n): #Aの1行目から
    c = []
    for j in range(l): #Bの1列目から
        result = 0
        for k in range(m): #Aのk列目およびBのk行目から
            result += a[i][k] * b[k][j]
        c.append(result)
    print(" ".join(map(str,c)))

Submission status: Accepted

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

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

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

for n in range(N):
    for l in range(L):
        c = 0
        for m in range(M):
            c += A[n][m] * B[m][l]
        print(c, end="")
        if l < L-1:
            print(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) ]

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

for i in range(n):
  data = input().split()
  for j in range(m):
    A[i][j] = int(data[j])
    
for i in range(m):
  data = input().split()
  for j in range(l):
    B[i][j] = int(data[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 i in range(n):
  print(*C[i])

Submission status: Accepted

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

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

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

for i in range(n):
    listC = []
    for j in range(l):
        ans = 0
        for k in range(m):
            ans += listA[i][k] * listB[k][j]
        listC.append(ans)
    print(' '.join(map(str, listC)))

Submission status: Accepted

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

A = [[] for i in range(n)]
B = [[] 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):
        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())
nm=[]
ml=[]
nl=[]

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

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


nl1=[]
s = 0

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

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

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

for line in C:
    print(*line)

Submission status: Accepted

Solution code:
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)]
c = [[0 for k in range(l)] for i in range(n)]

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

for j in range(m):
    lst =  list(map(int, input().split(' ')))
    
    for k in range(l):
        b[j][k] = lst[k]
        
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(list(map(str, c[i]))))

Submission status: Accepted

Solution code:
n, m, l = map(int,input().split())
nl = []
al = []
for i in range(n + m):
   nl.append(list(map(int,input().split())))
for j in range(n):
    for k in range(l):
        num = 0
        for o in range(m):
            num += nl[j][o]*nl[n+o][k]
        al.append(num)
    print(" ".join(map(str,al)))
    al.clear()

Submission status: Accepted

Solution code:
import operator 
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(map(operator.mul, tuple(A[i]), list(zip(*B))[j])) for j in range(l) ] for i in range(n) ]
print ('\n'.join([' '.join(map(str,i)) for i in C]))

Submission status: Accepted

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

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

for j in range(m):
    a2[j] = list(map(int, input().split()))
    
for i in range(n):
    line = []
    for j in range(l):
        c = 0
        for k in range(m):
            c += a1[i][k]*a2[k][j]
        line.append(str(c))
    print(" ".join(line))

Submission status: Accepted

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

for i in range(n):
        a.append(list(int(x) for x in input().split()))
for i in range(m):
        b.append(list(int(x) for x in input().split()))
for i in range(n):
    for j in range(l):
        w = 0
        for k in range(m):
            w += a[i][k] * b[k][j]
        else:
            c[i].append(w)

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

Submission status: Accepted

Solution code:
n,m,l=map(int,input().split())
lst1=[list(map(int,input().split())) for i in range(n)]
lst2=[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):
        ans[i][j]= str(sum( lst1[i][k]*lst2[k][j] for k in range(m)))
for A in ans:
    print(*A)

Submission status: Accepted

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

A = [list(map(int, input().rstrip().split())) for _ in range(n)]
#print(A)

B = [list(map(int, input().rstrip().split())) for _ in range(m)]
#print(B)


array = []
for i in range(n):
    lst = []
    for j in range(l):
        t = 0
        for k in range(m):
            s = A[i][k]*B[k][j]
            t += s
        lst.append(t)
    ans = " ".join([str(u) for u in lst])
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
line = input().split()
n = int(line[0])
m = int(line[1])
l = int(line[2])
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):
    line = input().split()
    for j in range(m):
        a[i][j] = int(line[j])

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

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 row in a:
    row_total = [0]*l
    for i, j in zip(row, b):
        row_total = list(map(lambda z: sum(z), zip(row_total, [i*k for k in j])))
    print(' '.join(map(str, row_total)))

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
A = [[]] * n
B = [[]] * 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]
        if j != l - 1:
            print(C[i][j], end = ' ')
        else:
            print(C[i][j], end = '')
    print('')