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

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

b = [[0 for j in range(l)] for i in range(m)]
for i in range(m):
    b[i] = 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(len(c)):
    print(*c[i])

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

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 = [[0 for j in range(m)] for i in range(n)]
B = [[0 for j in range(l)] for i in range(m)]
C = [[0 for j 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 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-1):
    print(C[i][j],end=' ')
  print(C[i][l-1],sep='')

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

Submission status: Accepted

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

C = []
for i in range(n):
    for k in range(l):
        for j in range(m):
            c = A[i][j]*B[j][k]
            C.append(c)
S = []
d = math.ceil(len(C)/(n*l))
r = [C[x: x+d] for x in range(0,len(C),d)]

for i in range(len(r)):
    s = sum(r[i])
    S.append(s)
    e = math.ceil(len(S)/n)
u = [S[y: y+e] for y in range(0,len(S),e)]
for i in range(len(u)):
    print(*u[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) :
        ans = 0
        for k in range(m) :
            ans += A[i][k] * B[k][j]
        if j == l-1 :
            print(ans)
        else :
            print(ans, end=" ")

Submission status: Accepted

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

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

Submission status: Accepted

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

for r in range(n):
    A[r][:] = list(map(int, input().split()))
for r in range(m):
    B[r][:] = list(map(int, input().split()))
for row in range(n):
    for col in range(l):
        for i in range(m):
            C[row][col] += A[row][i]*B[i][col]
    print(*C[row][:])

Submission status: Accepted

Solution code:
import sys
def mul_matrix(a, b):
   n = len(a)
   m = len(b)
   l = len(b[0])
   ans = []
   for i in range(n):
      s = []
      for j in range(l):
         sum = 0
         for k in range(m):
            sum += a[i][k] * b[k][j]
         s.append(sum)
      ans.append(s)      #行列の積を計算した結果をansに追加
   return ans

def main():
   n,m,l = [int(i) for i in sys.stdin.readline().strip().split(' ')]
   a = []
   b = []
   for i in range(n):
      data = [int(j) for j in sys.stdin.readline().strip().split(' ')]
      a.append(data)
   for i in range(m):
      data = [int(j) for j in sys.stdin.readline().strip().split(' ')]
      b.append(data)
   ans = mul_matrix(a, b)
   for i in ans:
      print(' '.join([str(j) for j in i]))
        
if __name__ == '__main__':
   main()

Submission status: Accepted

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

#print("n:%d, m:%d, l:%d"%(n, m, l))

nmlist=[]
for i in range(n):
    nm=list(map(int,input().split()))
    nmlist.append(nm)
#print(nmlist)

mllist=[]
for j in range(m):
    ml=list(map(int,input().split()))
    mllist.append(ml)
#print(mllist)


result = []

for i in range(n):
  for j in range(l):
    sum = 0
    for k in range(m):
      sum = sum + nmlist[i][k]*mllist[k][j]
    result.append(sum)

#print(result)


for o in range(1,len(result)+1):
    if o%l==0:
        print(result[o-1])
    else:
        print(result[o-1],end=' ')

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
A = [[0] * m for _ in range(n)]
B = [[0] * l for _ in range(m)]
C = [[0] * l for _ in range(n)]
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(m):
        A[i][j] = a[j]
for i in range(m):
    b = list(map(int, input().split()))
    for j in range(l):
        B[i][j] = b[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 - 1):
        print(C[i][j], end=' ')
    print(C[i][l - 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):
        num = 0
        for k in range(M):
            num += A[i][k] * B[k][j]
        C[i][j] = num
for l in range(N):
    print(*C[l])

Submission status: Accepted

Solution code:
#70 行列の積

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

Submission status: Accepted

Solution code:
num=list(map(int,input().split(" ")))
A=[list(map(int,input().split(" ")))for i in range(num[0])]
B=[list(map(int,input().split(" ")))for i in range(num[1])]
C=[[0]*num[2] for i in range(num[0])]

for i in range(num[0]):
    for j in range(num[2]):
        for k in range(num[1]):
            C[i][j]+=A[i][k]*B[k][j]
for i in C:
    print(" ".join(map(str,i)))

Submission status: Accepted

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

def acq_ab(n):
    a = []
    for i in range(n):
        if i == n:
            break
        ai = list(map(int, input().split()))
        a.append(ai)
    return a

def calc(a, b, n, m, l):
    ans = 0
    for i in range(n):
        for j in range(l):
            for k in range(m):
                ans = ans + a[i][k] * b[k][j]
            if j == l - 1:
                #print("j = {}".format(j))
                print(ans)
            else:
                #print("j = {}".format(j))
                print(ans, end=" ")
            ans = 0
    return 0

#a = [[1, 2], [0, 3], [4, 5]]
#b = [[1, 2, 1], [0, 3, 2]]
#c = calc(a, b, 3, 2, 3)
a = acq_ab(n)
b = acq_ab(m)
calc(a, b, n, m, l)

Submission status: Accepted

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

for i in range(1,n+1):
    P.append(input().split())
    
    
for j in range(1,m+1):
    Q.append(input().split())
   
    
for k in range(1,n+1):
    a=P[k-1]
    
    for p in range(1,m+1):
        b=Q[p-1]
        c=a[p-1]
        
        for q in range(1,l+1):
            d=int(c)*int(b[q-1])
            R.append(d)
          
    for r in range(l):
        for s in range(m):
            e+=R[r+l*s]
    
        if r<l-1:
            print(e,end=' ')
        else:
            print(e)
        e=0
    R=[]

Submission status: Accepted

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

Submission status: Accepted

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

lsta=[[int(a) for a in input().split()] for x in range(n)]
lstb=[[int(b) for b in input().split()] for y in range(m)]

for i in range(n):
    rows=[]
    for j in range(l):
        lstc=[]
        for k in range(m):
            c=lsta[i][k]*lstb[k][j]
            lstc.append(c)
        rows.append(sum(lstc))
    print(*rows)

Submission status: Accepted

Solution code:
n,m,l=map(int,input().split())
A=[[0 for c in range(m)]for d in range(n)]
B=[[0 for e in range(l)]for f in range(m)]
for a in range(n):
    A[a]=list(map(int,input().split()))
for b in range(m):
    B[b]=list(map(int,input().split()))
sum=[[0 for g in range(l)]for h in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            sum[i][j]=sum[i][j]+A[i][k]*B[k][j]
        if j!=l-1:
            print(sum[i][j],end=' ')
        else:
            print(sum[i][j])

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

Submission status: Accepted

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

A,B,C = [],[],[]

for i in range(n):
    a = list(map(int,input().strip().split()))
    A.append(a)
    c = [0] * l
    C.append(c)
    
for j in range(m):
    b = list(map(int,input().strip().split()))
    B.append(b)
    
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for x in C:
    print(*x)

Submission status: Accepted

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

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 range(n):
    print("%d" % mc[row][0], end="")
    for col in range(1, l):
        print(" %d" % mc[row][col], end="")
    print()

Submission status: Accepted

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


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

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

Submission status: Accepted

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

M = []

"""
a[0][0]*b[0][0]+a[0][1]*b[1][0]
a[0][0]*b[0][1]+a[0][1]*b[1][1]
a[0][0]*b[0][2]+a[0][1]*b[1][2]

a[1][0]*b[0][0]+a[1][1]*b[1][0]
a[1][0]*b[0][1]+a[1][1]*b[1][1]
a[1][0]*b[0][2]+a[1][1]*b[1][2]

a[2][0]*b[0][0]+a[2][1]*b[1][0]
a[2][0]*b[0][1]+a[2][1]*b[1][1]
a[2][0]*b[0][2]+a[2][1]*b[1][2]
"""
for i in range(0, len(a)):
    ci = []
    for k in range(0, int(l)):
        cik = 0
        for j in range(0,int(m)):
            cik = cik + int(a[i][j]) * int(b[j][k])
        ci = ci + [cik]
    M = M + [ci]


for i in range(int(n)):
    for j in range(int(l)):
        if j != int(l)-1:
            print(str(M[i][j]) + " ", end="")
        else:
            print(M[i][j])

Submission status: Accepted

Solution code:
N,M,L,*A = list(map(int, open(0).read().split()))
B = A[N*M:]
A = A[:N*M]

for n in range(N):
    ss = []
    for l in range(L):
        s = 0
        for m in range(M):
            a = A[n*M + m]
            b = B[m*L + l]
            s += a * b
        ss.append(s)
    print(" ".join(map(str, ss)))

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):
    lst=[0 for _ in range(l)]
    for j in range(l):
        sm=0
        for k in range(m):
            sm+=a[i][k]*b[k][j]
        lst[j]=str(sm)
    print(" ".join(lst))

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
list_a = []
list_b = []
list_c = []

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

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

B = []
for _ in range(y):
    B.append([int(x) for x in list(input().split())])


C = [[0] * z for _ in range(x)]

for k in range(z):
    for i in range(x):
        for j in range(y):
            C[i][k] += A[i][j] * B[j][k]

for i in range(len(C)):
    for j in range(len(C[i])):
        if j != len(C[i]) - 1:
            print("{} ".format(C[i][j]), end="")
        else:
            print(C[i][j])

Submission status: Accepted

Solution code:
dataset = input().split(" ")

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

A = []
for i in range(n):
    buf = input().split(" ")
    tmp = []
    for j in range(m):
        tmp.append(int(buf[j]))
    A.append(tmp)

B = []
for i in range(m):
    buf = input().split(" ")
    tmp = []
    for j in range(l):
        tmp.append(int(buf[j]))
    B.append(tmp)


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


for i in range(n):
    for j in range(l):
        print("%d" % (C[i*l + j]), end="")
        if j < l-1:
            print(" ", end="")
    print()

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
d=[]
for i in range(a):
    d.append(list(map(int,list(input().split()))))
e=[]
for i in range(b):
    e.append(list(map(int,list(input().split()))))
g=[]
f=[]
total=0
for k in range(a):
    for i in range(c):
        for j in range(b):
            total+=d[k][j]*e[j][i]
        f.append(total)
        total=0
    g.append(f)
    f=[]
for i in range(a):
    for j in range(c):
        if j==c-1:
            print("{}".format(g[i][j]),end= "") 
        else:
            print("{} ".format(g[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 = []

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

for C_c in C:
    print(*C_c)

Submission status: Accepted

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

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

for w in range(n):
    for h in range(l):
        tmp = 0
        for i in range(m):
            tmp += a[w][i] * b[i][h]
        c[w][h] = tmp

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

    c = []

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

    for line in c:
        print(*line)



resolve()

Submission status: Accepted

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

Submission status: Accepted

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


for i in range(n):
  c=''
  for j in range(l):
    cij=0
    for k in range(m):
      cij+=a[i][k]*b[k][j]
    if j==l-1:
      c+=str(cij)
    else:
      c+=str(cij)+' '
  print(c)

Submission status: Accepted

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

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

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

c = [[0] * l for i in range(n)]
# print(c)
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 i in range(n):
    print(c[i][0], end="")
    for j in range(1, l):
        print("", c[i][j], end="")
    print()

Submission status: Accepted

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

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

    ans_matrix=[[0]*L for _ in range(N)]
    for n in range(N):
        for l in range(L):
            tmp=0
            for m in range(M):
                tmp+=A[n][m]*B[m][l]
            ans_matrix[n][l]=tmp
    for ans in ans_matrix:
        print(*ans)

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
def mul(mx1, mx2):
    n = len(mx1)
    m = len(mx1[0])
    l = len(mx2[0])
    ans = [[None] * l for _ in range(n)]

    for i in range(n):
        for j in range(l):
            _e = 0
            for k in range(m):
                _e += mx1[i][k] * mx2[k][j]
            ans[i][j] = _e

    return ans


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

mx1 = []
mx2 = []

for _ in range(n):
    mx1.append([int(i) for i in input().strip().split()])

for _ in range(m):
    mx2.append([int(i) for i in input().strip().split()])

ans = mul(mx1, mx2)

for row in ans:
    print(" ".join([str(i) for i in row]))

Submission status: Accepted

Solution code:
N, M, L = [int(n) for n in input().split()]
A = []
for i in range(N):
  A.append([int(n) for n in input().split()])

B = []
for j in range(M):
  B.append([int(n) for n in input().split()])
BB = [list(b) for b in zip(*B)]

for i in range(N):
  x = []
  for j in range(L):
    x.append(sum([a*b for a,b in zip(A[i], BB[j])]))
  print(*x)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:

a = []
b = []
calc = 0
j = 0
k = 0

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

i = 0
while i < n:
    a.append(list(map(int, input().split())))
    i += 1

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

for i in range(n):
    for j in range(l):
        calc = 0

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

Submission status: Accepted

Solution code:
n, m, l = map(int,input().split())
a = []
e = []
for i in range(n):
    b = list(map(int,input().split()))
    a.append(b)
for i in range(m):
    d = list(map(int,input().split()))
    e.append(d)
for i in range(n):
    for j in range(l):
        f = 0
        for o in range(m):
            f += (a[i][o]*e[o][j])
        print(f,end='')
        if j != l-1:
            print(' ',end='')
    print()

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(n):
    a.append(list(map(int, input().split())))
for 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 = []
B = []

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

C = []
for n in range(N):
    tmp = []
    for l in range(L):
        total = 0
        for m in range(M):
            total += A[n][m] * B[m][l]
        tmp.append(total)
    C.append(tmp)

for c in C:
    str_c = [str(s) for s in c]
    str_c = " ".join(str_c)
    print(str_c)

Submission status: Accepted

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

elements_a = []
elements_b = []

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

for i in range(m):
    elements_b.append(list(map(int, input().split(' '))))

for ns in elements_a:
    for ls in range(l):
        result = 0
        for ms in range(m):
            result += ns[ms] * elements_b[ms][ls]
        if ls == l - 1:
            print(result)
        else:
            print(result, end =' ')

Submission status: Accepted

Solution code:
def vector_multiplication(A, B):
    res = [[0 for _ in range(len(B[0]))] for _ in range(len(A))]
    for i in range(len(A)):
        for j in range(len(B[0])):
            for k in range(len(B)):
                res[i][j] += A[i][k] * B[k][j]
    return res


n, m, l = list(map(int, input().split()))
A = [[int(x) for x in input().split()] for _ in range(n)]
B = [[int(x) for x in input().split()] for _ in range(m)]
ans = vector_multiplication(A, B)
for i in ans:
    print(' '.join(map(str,i)))

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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


for ki in range(n):
    j=[]
    for ko in range(l):
        k=0
        for no in range(m):
            k+=a[ki][no]*b[no][ko]
        j.append(k)
    c.append(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 = []

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

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

C = []

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

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

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
gyouretsu1 = []
gyouretsu2 = []
gyouretsu_ans = []
for i in range(n):
  gyouretsu1.append(list(map(int, input().split())))
for i in range(m):
  gyouretsu2.append(list(map(int, input().split())))
for i in range(n):
  gyou = []
  for j in range(l):
    factor = 0
    for k in range(m):
      factor += gyouretsu1[i][k]*gyouretsu2[k][j]
    gyou.append(str(factor))
  print(" ".join(gyou))

Submission status: Accepted

Solution code:
def print_list_list(list):
    for i in list:
        print(i[0],end="")
        for j in range(1, len(i)):
            print(" ", end="")
            print(i[j],end="")
        print()

def answer(list1, list2, n, m, l):
    c = []
    for i in range(n):
        temp_list = []
        for j in range(l):
            sum = 0
            for k in range(m):
                sum += list1[i][k]* list2[k][j]
            temp_list.append(sum)
        c.append(temp_list)
    return c

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

ans = answer(a, b, n, m, l)
print_list_list(ans)