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

Submission status: Accepted

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

a = []
for i in range(n):
    str = input()
    sp = str.split(' ')
    a_row = []
    for s in sp:
        a_row.append(int(s))
    a.append(a_row)

b = []
for i in range(m):
    str = input()
    sp = str.split(' ')
    b_row = []
    for s in sp:
        b_row.append(int(s))
    b.append(b_row)

c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    str = ''
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
            
        str += '{}'.format(c[i][j])
        if j < l - 1:
            str += ' '
    print(str)

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


for i in C:
    print(*i)

Submission status: Accepted

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

Submission status: Accepted

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

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

t = 0
for i in a:
    for x in range(l):
        for k in range(m):
            t += i[k]*b[k][x]            
        else:        
            z.append(t)
            t = 0
    else:
        ans.append(z)
        z =[]

for y in ans:
    print(*y)

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 = []
for _ in range(0,n):
    row = []
    row[:] = map(int, input().split())
    a.append(row)
#print(a)

b = []
for _ in range(0,m):
    row = []
    row[:] = map(int, input().split())
    b.append(row)
#print(b)

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

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

Submission status: Accepted

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

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

b=[[0]*l for i in range(m)]

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

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==0:
            print(c,end="")
        else:
            print(" "+str(c),end="")
    print()

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
a = []
b = []
ans = []
for x in range(n):
    a.append(list(map(int, input().split())))
for y in range(m):
    b.append(list(map(int, input().split())))

# print(a, b)
sub_total = []
for e in range(0, n):
    tm2 = []
    for f in range(0, l):
        tmp = []
        for g in range(0, m):
            tmp.append(a[e][g] * b[g][f])
            if len(tmp) == m:
                tm2.append(sum(tmp))
                tmp.clear()
                if len(tm2) == l:
                    print(*tm2)
                    tm2.clear()

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
A_matrix = []
for i in range(n):
    tmp_row = list(map(int, input().split()))
    A_matrix.append(tmp_row)
#print(A_matrix)
B_matrix = []
for i in range(m):
    tmp_row = list(map(int,input().split()))
    B_matrix.append(tmp_row)

#print(B_matrix)
C_matrix =  [[0]*l for i in range(n)] 
for i in range(n):
    for j in range(l):
        for k in range(m):
            C_matrix[i][j] +=  A_matrix[i][k]*B_matrix[k][j]


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 30 14:29:37 2019

@author: liang
"""

def showlist(list):
    for slist in list:
        stri = str()
        for s in slist:
            stri += str(s) + " "
        print(stri[:-1])
        
        
n , m , l = map(int,input().split())

alist = list()
blist = [list() for x in range(l)]


for i in range(n):
    alist.append(list(map(int,input().split())))
        
for x in range(m):
    tlist = list(map(int,input().split()))
    for s in range(l):
        blist[s].append(tlist[s])

clist = [list() for x in range(n)]
for j in range(n):
    for s in range(l):
        sum = 0
        for i in range(len(alist[j])):
            sum += alist[j][i] * blist[s][i]
        clist[j].append(sum)

showlist(clist)

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):
        ci = 0
        for k in range(m):
            ci += a[i][k] * b[k][j] 
        print("{}".format(str(ci)), end="")
        if j == l-1:
            print()
        else:
            print(" ", end="")

Submission status: Accepted

Solution code:
m,n,l=map(int,input().split(" ")) #m=3,n=2,l=3
matA=[list(map(int,input().split(" "))) for i in range(m)] #matA[3][2]
matB=[list(map(int,input().split(" "))) for i in range(n)] #matB[2][3]
matAB=[[0 for i in range(l)] for k in range(m)] #matAB[3][3]

ele=0
for k in range(l):
    for i in range(m):
        for j in range(n):
            matAB[i][k]+=matA[i][j]*matB[j][k]

#print(matAB)
for i in range(m):
    for j in range(l):
        if j!=l-1:
            print(matAB[i][j],end=" ")
        else:
            print(matAB[i][j])

Submission status: Accepted

Solution code:
n,m,l=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(n)]
B=[list(map(int,input().split())) for _ in range(m)]
for i in range(n):
    ans=[0]*l
    for j in range(l):
        for k in range(m):
            ans[j]+=A[i][k]*B[k][j]
    print(*ans)

Submission status: Accepted

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

matrixA = [list(map(int, input().split())) for _ in range(n)]
matrixB = [list(map(int, input().split())) for _ in range(m)]

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

for r in result:
    for i, num in enumerate(r):
        print(num, end='')
        if i != l-1:
            print(end=' ')
    print()

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
x = []
y = []
z = [[0 for i in range(c)] for j in range(a)]
for i in range(a):
    x.append(list(map(int,input().split())))
for i in range(b):
    y.append(list(map(int,input().split())))

for i in range(a):
    for j in range(c):
        tmp = 0
        for k in range(b):
            tmp += x[i][k] * y[k][j]

        z[i][j] = tmp

for i in range(a):
    for j in range(c):
        print(z[i][j],end="")
        if j != c-1:
            print(" ",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].extend(map(int,input().split()))
for i in range(m):
    B[i].extend(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(f"{C[i][j]}",end = "")
        if j != l-1:
            print(" ",end = "")
        else:
            print()

Submission status: Accepted

Solution code:
n, m, p = 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] * p for i in range(n)]

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

for i in range(n):
    for j in range(p):
        if j != p - 1:
            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=[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 range(n):
    print(*C[i])

Submission status: Accepted

Solution code:
n, m, l = [int(i) for i in input().split()]
a = []
b = []
c = [[0] * l for _ in range(n)]
for _ in range(n):
    a.append([int(i) for i in input().split()])
for _ in range(m):
    b.append([int(i) for i in input().split()])
for i in range(n):
    for j in range(l):
        c[i][j] = sum([a[i][k] * b[k][j] for k in range(m)])
for r in c:
    print(*r)

Submission status: Accepted

Solution code:
# Inputs

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

# Calculation
C = [[0 for a in range(l)] for b in range(n)]

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

# Output
for k in C:
    print(*k)

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()))
    A.append(a)

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

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

for x in range(n):
    for y in range(l):
        for z in range(m):
            C[x][y] += A[x][z]* B[z][y]

for row in range(n):
    print(C[row][0], end='')
    for col in range(1, l):
        print(' {}'.format(C[row][col]), 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)]
BT = [[bc[i] for bc in B] for i in range(l)]

for i in range(n):
    for j in range(l):
        print(sum([a * b for a, b in zip(A[i], BT[j])]), end='')
        if not 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 = [[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):
    print(*C[i], sep=' ')

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 k in range(m):
    B.append(list(map(int,input().split())))
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],end=' ')
        else:
            print(C[i][j],end='')
    print()

Submission status: Accepted

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

for _ in range(m):
    a = [int(x) for x in input().split()]
    for i,j in enumerate(a):
        B[_][i] = j

for row in range(n):
    for col in range(l):
        for k in range(m):
            C[row][col] += A[row][k]*B[k][col]
    for _ in range(l):
        if _ == l-1:
            print(C[row][_],end="")
            continue
        print(C[row][_],end="")
        print(" ", end="")
    print()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

b = []
c = []

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

for i in range(m):
    a = [int(x) for x in input().split()]
    c.append(a)
    
for i in range(n):
    for j in range(l):
        v = 0
        for k in range(m):
            v += b[i][k]*c[k][j]
        print(v,end="")
        if j < l-1:
            print(" ",end="")
    print()

Submission status: Accepted

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

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)

#print(A)
#print(B)

result=[[0 for i in range(l)] for j in range(n)] #row:n,column:l
#print(result)

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("i:",i,"j",j)
        result[i][j]=sum

#print(result)

for i in range(n):
    for j in range(l-1):
        print(result[i][j]," ",end="",sep="")
    print(result[i][l-1])

Submission status: Accepted

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

c = [[0]*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 e in c:
    print(*e)

Submission status: Accepted

Solution code:
#coding: utf-8

n, m, l = map(int, input().split())
mtxA = list()
mtxB = list()
for i in range(n):
    mtxA.append(list(map(int, input().split())))
for i in range(m):
    mtxB.append(list(map(int, input().split())))
for i in range(n):
    for j in range(l):
        if j > 0:
            print(' ', end = '')
        s = 0
        for k in range(m):
            s += mtxA[i][k] * mtxB[k][j]
        print(s, end = '')
        if j == l - 1:
            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(m)] for j in range(l)]

# 行列の読み込み
for i in range(n):
    A[i] = list(map(int, input().split()))
    
for i in range(m):
    tmp = list(map(int, input().split()))
    for j in range(l):
        B[j][i] = tmp[j]
    
ANS = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    for j in range(l):
        for a, b in zip(A[i], B[j]):
            ANS[i][j] += (a * b)

# プリントする
for i in range(n):
    for j in range(l):
        if j == 0:
            print(ANS[i][j], sep="", end="")
        else:
            print(" ", ANS[i][j], sep="", 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)] #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 = [[0] for j in range(n)]
B = [[0] for j in range(m)]
for i in range(n):
	a = list(map(int,input().split()))
	A[i] = a
for i in range(m):
	b = list(map(int,input().split()))
	B[i] = b
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 c in C:
	print(*c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
matrix1 = []
matrix2 = []
matrix3 = [[0 for i in range(c)]for j in range(a)]
for i in range(a):
    matrix1.append(list(map(int,input().split())))
for i in range(b):
    matrix2.append(list(map(int,input().split())))
    
for i in range(a):
    for j in range(c):
        for k in range(b):
            matrix3[i][j]+=matrix1[i][k]*matrix2[k][j]

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

Submission status: Accepted

Solution code:
n,m,l=map(int,raw_input().split())
a=[map(int,raw_input().split()) for i in xrange(n)]
b=[map(int,raw_input().split()) for i in xrange(m)]
c=[[0]*l for i in xrange(n)]

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

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:
def inputV(h):
	return [list(map(int,input().split())) for i in range(h)]

def calcC(A,B,i,j):
	cij = 0
	for k in range(m):
		cij += A[i][k]*B[k][j]
	return cij

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

A=inputV(n) #[n][m]

B=inputV(m) #[m][l]

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

Submission status: Accepted

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

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:
import sys,os,re
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations
sys.setrecursionlimit(10**6)

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

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
As = [list(map(int, input().split())) for i in range(n)]
Bs = [list(map(int, input().split())) for i in range(m)]
Cs = [[0]*l for i in range(n)]

for i in range(n):
    for j in range(l):
        s = 0
        for k in range(m):
            s += As[i][k]*Bs[k][j]
        Cs[i][j] = s
# print(Cs)
for i in range(n):
    print(*Cs[i])

Submission status: Accepted

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

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)]
kekka=[0*l]
for row in range(n):
	work=list(map(int,input().split()))
	for col in range(m):
		a[row][col]=work[col]
for row in range(m):
	work=list(map(int,input().split()))
	for col in range(l):
		b[row][col]=work[col]		

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

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

Submission status: Accepted

Solution code:
lg = []
rg = []
la = []
n, m, l = map(int, input().split())
for h in range(n):
    s = list(map(int, input().split()))
    lg.append(s)
for h in range(m):
    t = list(map(int, input().split()))
    rg.append(t)
for i in range(n):
    for j in range(l):
        p = 0
        for q in range(m):
            p = p + lg[i][q] * rg[q][j]
        # p = lg[i][k] * rg[k][j] + lg[i][k + 1] * rg[k + 1][j]
        la.append(p)
    print(" ".join(map(str, (la))))
    # print(la)
    la = []

Submission status: Accepted

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

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

for i in range(n):
    for j in range(l):
        cx = 0
        for k in range(m):
            cx += l1[i][k]*l2[k][j]    
        if j!=l-1:
            print(cx,end = ' ')
        else:
            print(cx)
   # print()

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
ma = []
mb = []
mc = [[0 for i in range(l)] for i in range(n)]
for i in range(n):
    ma.append(list(map(int, input().split())))
for i in range(m):
    mb.append(list(map(int, input().split())))
for i in range(n):
    for j in range(l):
        for k in range(m):
            mc[i][j] += ma[i][k] * mb[k][j]

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

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

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

Submission status: Accepted

Solution code:
def inputTable(a):
	lit=[]
	for aa in range(a):
		lit.append(list(map(int,input().split())))
	return lit
n,m,l=map(int,input().split())
A=inputTable(n)
C=[[0 for q in range(l)]for p in range(n)]
B=inputTable(m)
for a in range(n):
	for b in range(l):
		for c in range(m):
			C[a][b]+=A[a][c]*B[c][b]
for aa in range(n):
	for aaa in range(l):
		if  aaa==l-1:
			print(str(C[aa][aaa]),end='')
		else:
			print(str(C[aa][aaa])+' ',end='')
	print()

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


main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

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

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n, m, l = map(lambda x: int(x), input().split())
    a_matrix = [[0] * m] * n
    b_matrix = [[0] * l] * m

    for idx in range(n):
        a_matrix[idx] = list(map(lambda x: int(x), input().split()))

    for idx in range(m):
        b_matrix[idx] = list(map(lambda x: int(x), input().split()))

    for row_idx in range(n):
        one_row_result = []
        for col_idx in range(l):
            one_row_result.append(sum(
                [a_matrix[row_idx][elem] * b_matrix[elem][col_idx]
                 for elem in range(m)]
            ))
        print(" ".join([str(elem) for elem in one_row_result]))

Submission status: Accepted

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

A = []
B = []

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

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

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