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:
def main():
    n, m, l = tuple(map(int, input().split()))
    matA = [[0 for j in range(m)] for i in range(n)]
    matB = [[0 for k in range(l)] for j in range(m)]
    matC = [[0 for k in range(l)] for i in range(n)]

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

    for j in range(m):
        tmp = list(map(int, input().split()))
        for k in range(l):
            matB[j][k] = tmp[k]


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

    for i in range(n):
        for k in range(l):
            if k == l-1:
                print(matC[i][k])
            else:
                print(matC[i][k], end=' ')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n, m, l = map(int, input().split())
    A, B = [], []
    for _ in range(n):
        A.append(list(map(int, input().split())))
    for _ in range(m):
        B.append(list(map(int, input().split())))
    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 line in C:
        print(' '.join(map(str, line)))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    a = readMatrix(n, m)
    b = readMatrix(m, l)

    printMatrix(multiplyAB(a, b))

def readMatrix(r, c):
    m = []
    for _ in range(r):
        m.append([int(x) for x in input().split()])

    return m

def multiplyAB(a, b):
    n = len(a)
    m = len(b)
    l = len(b[0])

    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]

    return c

def printMatrix(m):
    for r in m:
        print(' '.join([str(x) for x in r]))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
A_ele = []
B_ele = []
C_ele = []
ele = [int(x) for x in input().split()]
for i in range(ele[0]):
    A_ele.append([int(x) for x in input().split()])
for i in range(ele[1]):
    B_ele.append([int(x) for x in input().split()])
for i in range(ele[0]):
    C_ele.append([])
    for j in range(ele[1]):
        for k in range(ele[2]):
            if j == 0:
                C_ele[i].append(0)
            C_ele[i][k] = C_ele[i][k] + A_ele[i][j] * B_ele[j][k]
for i in range(ele[0]):
    print(' '.join(map(str,C_ele[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 = [[sum([a[n][m] * b[m][l] for m in range(m)]) for l in range(l)] for n in range(n)]
for ans in c: print(*ans)

Submission status: Accepted

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

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

matrix_B_transposed  = list(map(list, zip(*matrix_B)))

for a in matrix_A:
    c = []
    for bt in matrix_B_transposed:
        c.append(sum(x * y for (x, y) in zip(a, bt)))
    print(*c)

Submission status: Accepted

Solution code:
a = input().split()
x = []
y = []
z = []
a[0] = int(a[0])
a[1] = int(a[1])
a[2] = int(a[2])
for i in range(a[0]):
    b = input().split()
    x.append(b)
    z.append([])
for i in range(a[1]):
    b  = input().split()
    y.append(b)
for i in range(a[0]):
    for j in range(a[2]):
        z[i].append(0)    
for i in range(a[0]):
    for j in range(a[2]):
        for k in range(a[1]):
            z[i][j] += int(x[i][k])*int(y[k][j])
for i in range(len(z)):
    for j in range(a[2]):
        z[i][j] = str(z[i][j])
for i in z:
    gam = " ".join(i)
    print(gam)

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 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):
    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(zip(*[list(map(int, input().split())) for _ in range(m)]))
# やっぱやめます
B = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
    line = []
    for j in range(l):
        ele = 0
        for k in range(m):
            ele += A[i][k]*B[k][j]
        line.append(ele)
    print(" ".join(list(map(str, line))))

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 for _ in range(l)] for _ 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 row in C:
    print(' '.join(list(map(str, row))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nml=input().split()
n,m,l=int(nml[0]),int(nml[1]),int(nml[2])
A_=[input() for i in range(n)]
B_=[input() for i in range(m)]
A,B=[],[]
for i in range(n):
    A_[i]=A_[i].split()
for i in A_:
    A.append(list(map(lambda i:int(i),i)))
for i in range(m):
    B_[i]=B_[i].split()
for i in B_:
    B.append(list(map(lambda i:int(i),i)))
AB=[]
for i in range(n):
    AB.append([])
for i in range(n):
    for j in range(l):
        AB[i].append(0)
for i in range(n):
    for j in range(l):
        for k in range(m):
            AB[i][j]+=(A[i][k]*B[k][j])
for i in AB:
    print(*i)

Submission status: Accepted

Solution code:
f = open(0)
N, M, L = map(int, f.readline().split())
A = [list(map(int, f.readline().split())) for i in range(N)]
B = [list(map(int, f.readline().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:
n,m,l = input().split()

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

matrix_A = [[0]*m for i in range(n)]
matrix_B = [[0]*l for j in range(m)]
matrix_C = [[0]*l for k in range(n)]
box_a = []
box_b = []
box_c = 0

for a in range(n):
    
    box_a = input().split()
    
    for b in range(m):
        
        matrix_A[a][b] = int(box_a[b])
        
    
for c in range(m):
    
    box_b = input().split()
    
    for d in range(l):
        
        matrix_B[c][d] = int(box_b[d])
        
            
for e in range(n):
    
    for f in range(l):
        
        for g in range(m):
            box_c += matrix_A[e][g] * matrix_B[g][f]
        
        
        matrix_C[e][f] = box_c
        box_c = 0
    
    print(" ".join(map(str,matrix_C[e])))

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(sum)
        else:print(sum,end=" ")

Submission status: Accepted

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

for i in range(n):
    for j in range(l):
        GOMI = 0
        for k in range(m):
            GOMI += FUCK[k][j]*YEAH[i][k]
        if j!=l-1:
            print(GOMI,end=" ")
        else:
            print(GOMI,end="")
    print()

Submission status: Accepted

Solution code:
from sys import stdin

n, m, l = [int(x) for x in stdin.readline().rstrip().split()]
a = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(n)]
b = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(m)]
c = [[0] *l for _ in range(n)]

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

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

# # 動作確認用のインプット
# with open(file='input_itp1_7_d_1.txt', mode='r', encoding='utf8') as input:
#     n, m, l = map(int, next(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] = [int(i) for i in next(input).split()]
#     print(A)
#     for i in range(m):
#         B[i] = [int(i) for i in next(input).split()]
#     print(B)

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

# # 動作確認用のインプット
# with open(file='input_itp1_7_d_1.txt', mode='r', encoding='utf8') as input:
#     n, m, l = map(int, next(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] = [int(i) for i in next(input).split()]
#     print(A)
#     for i in range(m):
#         B[i] = [int(i) for i in next(input).split()]
#     print(B)

for row in range(n):
    for col in range(l):
        tmp = 0
        for k in range(m):
            tmp += A[row][k] * B[k][col]
        C[row][col] = tmp
    print(' '.join(map(str, C[row])))

Submission status: Accepted

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

def get_matrix(n):
	matrix = []
	for i in range(n):
		matrix.append(list(map(int, input().split())))
	return matrix

A = get_matrix(n)
B = get_matrix(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(sum)
		else: print(sum, end=' ')

Submission status: Accepted

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

for row in range(m):
    matrixR[row] = [int(i) for i in input().split()]
c = [[0] * l for i in range(n)]
for ansColumn in range(l):
    for row in range(n):
        for column in range(m):
            c[row][ansColumn] = c[row][ansColumn] + matrixL[row][column] * matrixR[column][ansColumn]
for row in range(n):
    for column in range(l):
        if column == l -1:
            print(c[row][column])
        else:
            print("%d " %c[row][column], end ="")

Submission status: Accepted

Solution code:
x=[]
y=[]
n=list(map(int,input().split()))

for i in range(n[0]):
	x.append(list(map(int,input().split())))
for i in range(n[1]):
	y.append(list(map(int,input().split())))
	
for i in range(n[0]):
	a=[]
	for j in range(n[2]):
		b=0
		for k in range(n[1]):
			f=x[i][k]*y[k][j]
			b+=f
		a.append(b)
	print(' '.join(list(map(str,a))))

Submission status: Accepted

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

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  k in range(n):
    for o in range(l):
        sum = 0
        for p in range(m):
            sum += (a[k][p] * b[p][o])
        print(sum, end = "")
        if o != l-1:
            print(" ", end = "")
    print()

Submission status: Accepted

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

t1 = [[0 for i in range(m)] for j in range(n)]
t2 = [[0 for i in range(l)] for j in range(m)]
t3 = [[0 for i in range(l)] for j in range(n)]

i = 0
while i < n:
  t1[i] = list(int(x) for x in input().split())
  i += 1

i = 0
while i < m:
  t2[i] = list(int(x) for x in input().split())
  i += 1

# cal t3
i = 0
while i < n:
  j = 0
  while j < l:
    k,c = 0,0
    while k < m:
      #print(str(i) + " " + str(k))
      c += t1[i][k] * t2[k][j]
      k += 1
    if j != 0:
      print(' ', end='')
    print(c, end='')
    j += 1
  print ('')
  i += 1

Submission status: Accepted

Solution code:
n,m,l=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
B=[list(map(int,input().split())) for i in range(m)]
C=[[0]*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("%d"%(C[row][0]),end="")
    for col in range(1,l):
        print(" %d"%(C[row][col]),end="")
    print()

Submission status: Accepted

Solution code:

n1,n2,n3 = map(int,input().split(" "))

list1 = [list(map(int,input().split(" "))) for _ in range(n1)]
list2 = [list(map(int,input().split(" "))) for _ in range(n2)]

mat = [[0 for _ in range(n3)] for _ in range(n1)]
for i in range(n1):
	for j in range(n2):
		for k in range(n3):
			mat[i][k] += list1[i][j] * list2[j][k]

for m in mat:
	print(*m)

Submission status: Accepted

Solution code:

n1,n2,n3 = map(int,input().split(" "))

list1 = [list(map(int,input().split(" "))) for _ in range(n1)]
list2 = [list(map(int,input().split(" "))) for _ in range(n2)]

mat = [[0 for _ in range(n3)] for _ in range(n1)]
for i in range(n1):
	for j in range(n3):
		for k in range(n2):
			mat[i][j] += list1[i][k] * list2[k][j]

for m in mat:
	print(*m)

Submission status: Accepted

Solution code:
n1,n2,n3 = map(int,input().split(" "))

list1 = [list(map(int,input().split(" "))) for _ in range(n1)]
list2 = [list(map(int,input().split(" "))) for _ in range(n2)]

mat = [[0 for _ in range(n3)] for _ in range(n1)]

for i in range(n1):
	for j in range(n3):
		mat[i][j]= str(sum(list1[i][k] * list2[k][j] for k in range(n2)))

for m in mat:
	print(*m)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x, y, z = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(x)]
B = [list(map(int, input().split())) for _ in range(y)]
ans_s = []
ans = []

for i in range(x):
    ans_s = []
    for j in range(z):
        p = 0
        for k in range(y):
            p += A[i][k] * B[k][j]
        ans_s.append(p)
    ans.append((ans_s))

for i in ans:
    print(' '.join([str(v) for v in i]))

Submission status: Accepted

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

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

Submission status: Accepted

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

  print(' '.join(line))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in c:
    print(*i)

Submission status: Accepted

Solution code:
def print_matrix(m):
    for cnt in range(len(m)):
        print(" ".join(map(str, m[cnt])))


def mul(lhs, rhs):
    n = len(lhs)
    m = len(rhs)
    l = len(rhs[0])

    ret = [
        [
            sum([lhs[i][k] * rhs[k][j] for k in range(m)])
            for j in range(l)
            ]
        for i in range(n)
        ]

    return ret


if __name__ == '__main__':
    from sys import stdin

    n, m, l = (int(_) for _ in stdin.readline().rstrip().split())

    A = []
    for _ in range(n):
        A.append([int(_) for _ in stdin.readline().rstrip().split()])

    B = []
    for _ in range(m):
        B.append([int(_) for _ in stdin.readline().rstrip().split()])

    C = mul(A, B)

    print_matrix(C)

Submission status: Accepted

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

[print(*x) for x in [[sum(j*k for j,k in zip(x,y)) for y in zip(*b)]for x in a]]

Submission status: Accepted

Solution code:
n,m,l = map(int,input().split())
A=[]
B=[]
for i in range(n): A.append(list(map(int,input().split())))
for j in range(m): B.append(list(map(int,input().split())))
for A_r in A:
    print(" ".join(map(str,[sum([x*y for x,y in zip(A_r,[B_r[k] for B_r in B])]) for k in range(l)])))

Submission status: Accepted

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

for i in range(0, 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)]
#print(A)
#print(B)

for i in range(n):
  for j in range(l):
    youso=0
    for k in range(m):
      youso+=A[i][k]*B[k][j]
    if j==0:
      print(youso,end="")
    else:
      print("",youso,end="")
  print("")

Submission status: Accepted

Solution code:
[n,m,l] = map(int,raw_input().split())
A = [[0 for i in range(m)] for j in range(n)]
B = [[0 for 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):
    v = map(int,raw_input().split())
    for j in range(m):
        A[i][j] = v[j]
for i in range(m):
    v = map(int,raw_input().split())
    for j in range(l):
        B[i][j] = v[j]

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

Submission status: Accepted

Solution code:
n, m, l= map(int, raw_input().split())
A = [[0 for i in range(m)] for j in range(n)]
B = [[0 for 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 = map(int, raw_input().split())
    for j in range(m):
        A[i][j] = a[j]
for i in range(m):
    b = map(int, raw_input().split())
    for j in range(l):
        B[i][j] = b[j]
for i in range(n):
    ans = ""
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
        if(j == 0):
            ans += str(C[i][j])
        else:
            ans += " " + str(C[i][j])
    print(ans)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
n, m, l = list(map(lambda x: int(x), input().split(" ")))
A = list()
for i in range(n):
    A.extend([list(map(lambda x: int(x), input().split(" ")))])
B = list()
for i in range(m):
    B.extend([list(map(lambda x: int(x), input().split(" ")))])
C = list([[0 for l_ in range(l)]for n_ 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 a in C:
    print("%d" % a[0], end="")
    for b in a[1:]:
        print(" %d" % b, end="")
    print()

Submission status: Accepted

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

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

B = []
for j in xrange(0,m):
	line_B = map(int, raw_input().split())
	B.append(line_B)

C = []
for x in xrange(0,n):
	temp_list = []
	for y in xrange(0,l):
		temp = 0
		for z in xrange(0,m):
			temp = temp + A[x][z] * B[z][y]

		temp_list.append(temp)
		
	C.append(temp_list)
	temp_list = []
			

for k in xrange(0,n):
	if k > 0:
		print
	for h in xrange(0,l):
		print C[k][h],
print

Submission status: Accepted

Solution code:
n,m,l = map(int,raw_input().split(' '))
A = [ [0 for j in range(m)]for i in range(n)]
B = [ [0 for j in range(l)]for i in range(m)]
for i in range(n):
	A[i] = map(int,raw_input().split(' '))
for i in range(m):
	B[i] = map(int,raw_input().split(' '))	
for i in range(n):
	for j in range(l):
		sum = 0
		for k in range(m):
			sum += A[i][k]*B[k][j]
		print sum,
	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:
def f():return map(int,raw_input().split())
n,m,l=f()
A = [f() for _ in [0]*n]
B = [f() for _ in [0]*m]
C = [[0 for _ in [0]*l] for _ in [0]*n]
for i in range(n):
  for j in range(l):
    print sum([A[i][k]*B[k][j] for k in range(m)]),
  print

Submission status: Accepted

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

A = []
for idx in range(0,n):
    A.append([int(x) for x in raw_input().split()])

B = []
for idx in range(0,m):
    B.append([int(x) for x in raw_input().split()])

for line in range(0, n):
    result_list = []
    for idx1 in range(0, l):
        sum = 0
        for idx2 in range(0, m):
            sum += A[line][idx2] * B[idx2][idx1]
        result_list.append(sum)
    
    result_str = ""
    for result in result_list:
        result_str += str(result) + " "
    print result_str.rstrip()

Submission status: Accepted

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

a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
c = [[sum(ak * bk for ak, bk in zip(ai,bj)) for bj in zip(*b)] for ai in a]

for ci in c:
    print(*ci)

Submission status: Accepted

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

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

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

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

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

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

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

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

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

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

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

for nc in range(n):
    for lc in range(l):
        for mc in range(m):
            product[nc][lc] += A[nc][mc] * B[mc][lc]
        
for r in product:
    print(' '.join([str(d) for d in r]))

Submission status: Accepted

Solution code:
import sys
(n, m, l) = [int(i) for i in sys.stdin.readline().split()]

a = []
for i in range(n):
    a.append([int(i) for i in sys.stdin.readline().split()])
b = []
for i in range(m):
    b.append([int(j) for j in sys.stdin.readline().split()])

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n, m, l = [int(i) for i in input().split()]
    A = [[int(i) for i in input().split()] for j in range(n)]
    B = [[int(i) for i in input().split()] for j in range(m)]
    B = list(map(list, zip(*B))) # trace
    C = [[sum(map(lambda x,y: x*y, A[i], B[j])) for j in range(l)] for i in range(n)]
    for i in C:
        print(' '.join([str(x) for x in i]))

Submission status: Accepted

Solution code:
#coding:utf-8
#1_7_D 2015.4.7
n,m,l = map(int,input().split())
matrixA = [list(map(int,input().split())) for i in range(n)]
matrixB = [list(map(int,input().split())) for i in range(m)]

matrixAxB = [list(sum([matrixA[i][k] * matrixB[k][j] for k in range(m)]) for j in range(l)) for i in range(n)]

for row in matrixAxB:
    print(*row)

Submission status: Accepted

Solution code:
import sys

n, m, l = [ int( val ) for val in sys.stdin.readline().split( " " ) ]

matrixA = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( n ) ]
matrixB = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( m ) ]	
matrixC = [ [ 0 for row in range( l ) ] for row in range( n ) ]

output = []
for i in range( n ):
	for j in range( l ):
		for k in range( m ):
			matrixC[i][j] += ( matrixA[i][k] * matrixB[k][j] )
		output.append( "{:d}".format( matrixC[i][j] ) )
		output.append( " " )
	output.pop()
	output.append( "\n" )

output.pop()
print( "".join( output ) )

Submission status: Accepted

Solution code:
import sys

n, m, l = [ int( val ) for val in sys.stdin.readline().split( " " ) ]

matrixA = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( n ) ]
matrixB = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( m ) ]	
c = 0

output = []
for i in range( n ):
	for j in range( l ):
		c = 0
		for k in range( m ):
			c += ( matrixA[i][k] * matrixB[k][j] )
		output.append( "{:d}".format( c ) )
		output.append( " " )
	output.pop()
	output.append( "\n" )

output.pop()
print( "".join( output ) )

Submission status: Accepted

Solution code:
import sys

n, m, l = [ int( val ) for val in sys.stdin.readline().split( " " ) ]

matrixA = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( n ) ]
matrixB = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( m ) ]	
matrixC = [ [ sum( matrixA[i][k] * matrixB[k][j]  for k in range( m ) ) for j in range( l ) ] for i in range( n )  ]

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

Submission status: Accepted

Solution code:
n,m,l=map(int,raw_input().split())
matA=[map(int,raw_input().split()) for i in range(n)]
matB=[map(int,raw_input().split()) for j in range(m)]
for i in range(n):
	for j in range(l):
		 print sum([matA[i][k]*matB[k][j] for k in range(m)]),
	print

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