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 = [list(map(int, input().split())) for _ in [0]*n]
B = [list(map(int, input().split())) for _ in [0]*m]
C = [[0 for _ in range(l)] for _ in range(n)]

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# 定義、入力
n, m, l = (int(i) for i in 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] = [int(j) for j in input().split()]
for j in range(m):
    B[j] = [int(k) for k in input().split()]

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

# Cの出力
for row in C:
    L = [str(k) for k in row]
    L = " ".join(L)
    print(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 j in range(m)]
C = [[0]*l for k in range(n)]
for s in range(n):
    for t in range(l):
        for u in range(m):
            C[s][t] += A[s][u] * B[u][t]
for v in range(n):
    print(*C[v])

Submission status: Accepted

Solution code:
n,m,l=map(int,input().split())
A,B=[],[]
C=[[0 for x in range(l)] for y in range(n)]
for a in range(n):
    A.append([int(x) for x in input().split()])
for b in range(m):
    B.append([int(x) for x in input().split()])
for c in range(m):
    for d in range(n):
        for e in range(l):
            C[d][e]+=A[d][c]*B[c][e]
for h in C:
    print(" ".join(map(str,h)))

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
def intread():
    return [int(item) for item in input().split()]

[l,m,n]=[int(item) for item in input().split()]

gyoretuA=[]
gyoretuB = []

for i in range(l):
    gyoretuA.append(intread())

for i in range(m):
    gyoretuB.append(intread())


productedMat = []
#掛け算
for i in range(l):
    #行の抽出
    row = gyoretuA[i]
    newrow=[]
    for j in range(n):
        #列の抽出
        col=[row[j]for row in gyoretuB]
        newrow.append(sum([a*b for a,b in zip(row,col)]))
    productedMat.append(newrow) 

for row in productedMat:
    print(*row)

Submission status: Accepted

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


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

a = getSomeInputListInt(n)
b = getSomeInputListInt(m)

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

for i in range(n):
    for j in range(l):
        tmp_a = a[i]
        tmp_b = [b[k][j] for k in range(m)]

        tmp_ans = 0
        for k in range(len(a[i])):
            tmp_ans += tmp_a[k]*tmp_b[k]
        ans[i][j] = tmp_ans

for row in ans:
    print(*row, 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 i in range(m):
    B.append(list(map(int, input().split())))

C = []
for i in range(n):
    c = []
    for j in range(l):
        b_row = [b[j] for b in B]
        c.append(sum([ a * b for a, b in zip(A[i], b_row)]))
    C.append(c)

for c in C:
    print(" ".join(map(str, c)))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

for i in range(l):
    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 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] += A[x][z]*B[z][y]

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())
c1=[list(map(int,list(input().split()))) for i in range(n)]
c2=[list(map(int,list(input().split()))) for i in range(m)]

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

for i in range(n):
    for j in range(l):
        for k in range(m):
            c3[i][j]+=c1[i][k]*c2[k][j]

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

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
n_Matrix = [list(map(int, input().split())) for i in range(n)]
m_Matrix = [list(map(int, input().split())) for i in range(m)]
ans = []
for i in n_Matrix:
  count = 0
  result = []
  for j in range(l):
    total = 0
    for k in range(len(i)):
      total += i[k] * m_Matrix[k][count]
    result.append(total)
    count += 1
  ans.append(result)
for a in ans:
  out = ""
  for b in a:
    out += str(b) + " "
  
  print(out[:-1])

Submission status: Accepted

Solution code:

N, M, L = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
B = [list(map(int, input().split())) for _ in range(M)]

C = [[0] * L for _ in range(N)]
for i in range(N):
    for j in range(L):
        for k in range(M):
            C[i][j] += B[k][j] * A[i][k]
[print(*c) for c in C]

Submission status: Accepted

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

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

for i in range(m):
  tmp = list(map(int, input().split()))
  for j in range(l):
    b[i][j] = tmp[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(0,n):
  print("%d"%(c[i][0]),end="")
  for j in range(1,l):
    print(" %d"%(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)] #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] += A[x][z]*B[z][y]

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 = list(map(int, input().split()))

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

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

Submission status: Accepted

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

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+=a[i][k]*b[k][j]
    ans.append(c)
    c=0
  print(" ".join(map(str,ans)))
  ans.clear()

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

Submission status: Accepted

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

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

# 計算
c = list()
for a_line in a:
    c_line = [0 for num in range(l)]
    for i in range(m):
        for j in range(l):
            c_line[j] += a_line[i] * b[i][j]
# c.append(c_line)
    c_line = [str(c_num) for c_num in c_line]
    print(' '.join(c_line))

Submission status: Accepted

Solution code:
def outputList(l):
  r = len(l)
  c = len(l[0])
  
  if r==1 and c==1:
    print(l[0][0])
  else:
    for i in range(r):
      for j in range(c-1):
        print(f'{l[i][j]} ',end='')
      print(l[i][j+1])


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

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

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

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

outputList(c)

Submission status: Accepted

Solution code:
A = []
B = []
C = []
n, m, l = list(map(int, input().split()))
for a in range(n):
    cTmp = []
    for b in range(l):
        cTmp.append([])
    C.append(cTmp)
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 x in range(n):
    for y in range(l):
        cTmp2 = 0
        for z in range(m):
            cTmp2 += A[x][z] * B[z][y]
        C[x][y] = cTmp2
for i in range(n):
    for k in range(l-1):
        print(C[i][k], end=" ")
    print(C[i][l-1])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

for i in result:print(*i, sep=' ')

Submission status: Accepted

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

for i in range(n):
    for j in range(l):
        print(sum([A[i][k] * B[k][j] for k in range(m)]), end=" " if j < l - 1 else "\n")

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

for i in range(n):
    for j in range(l):
        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("%d " % (c[i][j]), end="")
        else:
            print("%d" % (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:
def main(N, M, L, a, b):
    results = [[0]*L for i in range(N)]
    for n in range(N):
        for l in range(L):
            for m in range(M):
                results[n][l] += a[n][m]*b[m][l]
    results = [" ".join(map(str, i)) for i in results]
    return '\n'.join(map(str, results))


if __name__ == "__main__":
    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)]
    print(main(N, M, L, a, b))

Submission status: Accepted

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

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

answer = []
for i in range(n):
    answer_c = []
    for j in range(l):
        answer_cc = 0
        for k in range(m):
            answer_cc += a[i][k] * b[k][j]
        answer_c.append(answer_cc)
    answer.append(answer_c)

for a in answer:
    print(*a)

Submission status: Accepted

Solution code:
sc = input().split()
n = int(sc[0])
m = int(sc[1])
l = int(sc[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)]

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

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(' {}'.format(x), end = '')
    print('')

Submission status: Accepted

Solution code:
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m, l = map(int, readline().split())
A = [[int(x) for x in readline().split()] for _ in range(n)]
B = [[int(y) for y in readline().split()] for _ in range(m)]
lis = [[0] * l for _ in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            lis[i][j] += A[i][k] * B[k][j]
for i in lis:
    print(*i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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

for row in range(n):
    arow = list(map(int, input().split()))
    for j in range(m):
        A[row][j] = arow[j]

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

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

for row in range(n):
    for col in range(l):
        if col < l - 1:
            print(C[row][col], end=" ")
        else:
            print(C[row][col], 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):
    tmpA = list(map(int, input().split()))
    for j in range(m):
        a[i][j] = tmpA[j]

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

Submission status: Accepted

Solution code:
n,m,l = map(int,input().split())
a=[]
b=[]
c=[]
for i in range(n):
  a.append([int(i) for i in input().split()])
for i in range(m):
  b.append([int(i) for i in input().split()])
tb =  []
for i in range(l):
  tb_row=[]
  for vector in b:
    tb_row.append(vector[i])
  tb.append(tb_row)
for i in a:
  c_row=[]
  for j in tb:
    c_row.append(sum(x*y for (x,y)in zip(i,j)))
  c.append(c_row)
for i in c:
  print(*i)

Submission status: Accepted

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

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

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

ans = []

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

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

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):
    s = list(map(int, input().split()))
    for j in range(m): a[i][j] = s[j]
for i in range(m):
    s = list(map(int, input().split()))
    for j in range(l): b[i][j] = s[j]
for i in range(n):
    for j in range(l):
        s = 0
        for x in range(m):
            s += a[i][x] * b[x][j]
        c[i][j] = s
for i in range(n):
    for j in range(l):
        if j == (l - 1):
            print(c[i][j])
        else:
            print(c[i][j], "", end = "")

Submission status: Accepted

Solution code:
def main(n,m,l,a,b):
    ans = [[0]*l for _ in range(n)]
    _sum = 0
    for i in range(n):
        for j in range(l):
            for k in range(m):
                _sum += a[i][k]*b[k][j]
            ans[i][j] = _sum
            _sum = 0
    for x in ans:
        print(*x)

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)]
main(n,m,l,a,b)

Submission status: Accepted

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

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

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

for i in ans:
    print(*i)

Submission status: Accepted

Solution code:
nml = input()
nml = nml.split()
n,m,l = nml
m,n,l =int(m),int(n),int(l)
NM = list()
ML = list()
NL = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    nm = input()
    nm = nm.split()
    NM.append(nm)
for j in range(m):
    ml = input()
    ml = ml.split()
    ML.append(ml)
for i in range(n):
    for a, A in enumerate(NM[i]):
        for b, B in enumerate(ML[a]):
            NL[i][b] = NL[i][b] + int(A)*int(B)
else:
    for a, A in enumerate(NL):
        p = ''
        for b, B in enumerate(NL[a]):
            p = p + ' {}'.format(B)
        else:
            print(p[1:])

Submission status: Accepted

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

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

for i in AB:
    print(*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] = 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("%d" %C[i][0], end="")
    for j in range(1, l):
        print(" %d" %C[i][j], end="")
    print()

Submission status: Accepted

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

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):
    c = list()
    for j in range(l):
        total = 0
        for k in range(m):
            total += a[i][k] * b[k][j]
        c.append(total)
    print(*c)

Submission status: Accepted

Solution code:
a, b, c = map(int,input().split())

xs = [list(map(int, input().split())) for i in range(a)]
ys = [list(map(int, input().split())) for i in range(b)]
ss = []
for i in range(a):
    rs = []
    for k in range(c):
        ppp=0
        for j in range(b):
            ppp+=xs[i][j] * ys[j][k]
        rs.append(ppp)
    ss.append(rs)

for i in ss:
    print(" ".join(map(str,i)))

Submission status: Accepted

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

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

for c in C:
    print(*c)

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

for _c in c:
    print(*_c)

Submission status: Accepted

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

for i in range(n):
    print(*c[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):
        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 = (int(x) for x in input().split())

a = []

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

b = []

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

c = []

## cij = ai1 * b1j + ai2 * b2j + ....

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

for ci in c:
    
    flag = True
    for cij in ci:
        if flag:
            flag = False
        else:
            print(" ", end="")
        print(cij, 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)] 
ANS = [[0]*L for i in range(N)] 


for i in range(N):
    for j in range(L):
        for k in range(M):
            ANS[i][j] += B[k][j]*A[i][k]

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

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 = list(map(int, input().split()))

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

answer = []
for i in range(n):
    calcSum = []
    for j in range(l):
        calc = []
        for k in range(m):
            calc.append(a[i][k] * b[k][j])
        calcSum.append(sum(calc))

    answer.append(calcSum)

[print(*answer[i]) for i in range(len(answer))]

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

Submission status: Accepted

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

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

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

for i in range(n):
	ans =''
	for j in range(l):
		num = 0
		for x in range(m):
			num += nm[i][x] * ml[x][j]	
		ans += str(num) + ' '
	print(ans.rstrip(' '))