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:
# AOJ ITP1_7_D

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    a = numinput()
    n = a[0]; m = a[1]; l = a[2]
    A = []; B = []; C = []

    for i in range(n):
        A.append(numinput())
    for j in range(m):
        B.append(numinput())

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

    for i in range(n):
        _str_ = ""
        for k in range(l - 1):
            _str_ += str(C[i][k]) + " "
        _str_ += str(C[i][l - 1])
        print(_str_)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

B = list(zip(*B))

for i, line_A in enumerate(A):
    for j, line_B in enumerate(B):
        for x, y in zip(line_A, line_B):
            C[i][j] += x * y

for line in C:
    for i, x in enumerate(line):
        if i == l - 1:
            print(x)
        else:
            print(x, end=" ")

Submission status: Accepted

Solution code:
import sys

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

a = [[0 for x in range(m)] for y in range(n)]
b = [[0 for x in range(l)] for y in range(m)]
c = [[0 for x in range(l)] for y in range(n)]

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

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

for i in range(n):
	for j in range(l):
		sum = 0
		for k in range(m):
			sum += a[i][k] * b[k][j]
		c[i][j] = sum
		
for i in range(n):
	for j in range(l):
		sys.stdout.write(str(c[i][j]))
		if j != l - 1:
			sys.stdout.write(' ')
	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())))
for i in range(n):
    li = [sum([a[i][j]*b[j][k] for j in range(m)]) for k in range(l)]
    print(' '.join(map(str, li)))

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

Submission status: Accepted

Solution code:
n, m, l = map(int, input().split())
A = [[] for a in range(n)]
B = [[] for b in range(m)]
C = [[0 for c in range(l)] for d in range(n)]
for a in A:
    a += list(map(int, input().split()))
for b in B:
    b += list(map(int, input().split()))
for k,x in enumerate(C):
    for y in range(l):
        for z in range(m):
            C[k][y] += A[k][z]*B[z][y]
for x in C:
    for k,y in enumerate(x):
        if k == l-1:
            print(y)
        else:
            print(y,end=" ")

Submission status: Accepted

Solution code:
# Matrix Multiplication

info = [int(i) for i in input().rstrip().split()]
n = info[0]
m = info[1]
l = info[2]

matrixA = []
matrixB = []
for i in range(n):
    row = [int(j) for j in input().rstrip().split()]
    matrixA.append(row)
for j in range(m):
    row = [int(k) for k in input().rstrip().split()]
    matrixB.append(row)
# print(matrixA)
# print(matrixB)

for i in range(n):
    multipleRow = []
    for k in range(l):
        total = 0
        for j in range(m):
            total += matrixA[i][j] * matrixB[j][k]
        multipleRow.append(str(total))
    # print(multipleRow)
    print(' '.join(multipleRow))

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

Submission status: Accepted

Solution code:
n, m, l = list(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):
	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(*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 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 row in range(n):
    print(str(C[row][0]), end = "")
    for i in range(1,l):
        print(f" {C[row][i]}", end = "")
    print()

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

for i in range(n):
    c = []
    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:
x=[]
y=[]
result=[]
num=input().split(' ')
for i in range(0,int(num[0]),1):
    num1=input().split(' ')
    x.append(num1)
for j in range(0,int(num[1]),1):
    num2=input().split(' ')    
    y.append(num2)
for k in range(0,int(num[0]),1):
    a=[]
    for j in range(0,int(num[2]),1):
        a.append(0)
    result.append(a)    
for i in range(len(x)):  
   for j in range(len(y[0])):  
       for k in range(len(y)):  
            result[i][j] +=int(x[i][k]) * int(y[k][j])
for r in range(0,int(num[0]),1):
    for j in range(0,int(num[2]),1):
        if j==int(num[2])-1:
            print(result[r][j])
        else:    
           print(result[r][j],end=" ")
    if r==int(num[0])-1:
        break

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#ITP1_7_D
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):
        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][-1])

Submission status: Accepted

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

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

a = []
b = []

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

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

Submission status: Accepted

Solution code:


N,M,L = map(int,input().split())

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

for x in range(N):
    for y in range(L):
        for z in range(M):
            ANS[x][y]+=B[z][y]*A[x][z]
            
for row in range(N):
    print("%d"%ANS[row][0],end="")
    for col in range(1,L):
        print(" %d"%(ANS[row][col]),end="")
    print()

Submission status: Accepted

Solution code:
import sys;

def mul_matrix(a, b):
    n = len(a);
    m = len(b);
    l = len(b[0]);
    
    ans = [];

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

            new_row.append(sum);

        ans.append(new_row);
    
    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())
a=list()
b=list()
for i in range(n):
    x=list(map(int,input().split()))
    a.append(x)
for i in range(m):
    y=list(map(int,input().split()))
    b.append(y)
for i in range(n):
    line=list()
    for j in range(l):
        sum=0
        for k in range(m):
            sum+=a[i][k]*b[k][j]
        line.append(sum)
    print(" ".join(list(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 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:
n, m, l = map(int, input().split())

A = []
B = []

for i in range(n) :
    A.append([int(a) for a in input().split()])
    
for j in range(m) :
    B.append([int(b) for b in input().split()])

C = []
L = []
s = 0

for i in range(l) :
    for j in range(n) :
        for k in range(m) :
            s += A[j][k] * B[k][i]
        
        L.append(s)
        s = 0
    
    C.append(L[i * n : i * n + n])
        
for i in range(n) :
    for j in range(l) :
        if j == l - 1 :
            print(C[j][i])
        else :
            print(C[j][i], end = " ")

Submission status: Accepted

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

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

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

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

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

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:
# 7_D
n,m,l=map(int,input().split())
A=[[0 for j in range(m)]for k in range(n)]
B=[[0 for j in range(l)]for k in range(m)]
C=[[0 for j in range(l)]for k in range(n)]
for j in range(n):
    var=list(map(int,input().split()))
    A[j]=var
for j in range(m):
    var=list(map(int,input().split()))
    B[j]=var

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

for line in C:
    length=len(line)
    for col in line:
        length-=1
        if length ==0 :
            print(str(col))
        else:
            print(str(col)+" ",end='')

Submission status: Accepted

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

for i in a:
    result = []
    for j in zip(*b):
        result.append(sum([a * b for (a,b) in zip(i, j)]))
    print(*result)

Submission status: Accepted

Solution code:
lst1=[]
lst2=[]
lst3=[]
answer_lst=[]
n,m,l=(int(x) for x in input().split())
for a in range(n):
    child_lst1=[]
    for b in input().split():
        child_lst1.append(int(b))
    lst1.append(child_lst1)
for c in range(m):
    child_lst2=[]
    for d in input().split():
        child_lst2.append(int(d))
    lst2.append(child_lst2)
for e in range(l):
    child_lst3=[]
    for f in lst2:
        child_lst3.append(f[e])
    lst3.append(child_lst3)
for g in range(1,n+1):
    child_lst4=[]
    need_lst1=lst1[g-1]
    for h in range(1,l+1):
        value=0
        need_lst2=lst3[h-1]
        for i in range(1,m+1):
            value+=need_lst1[i-1]*need_lst2[i-1]
        child_lst4.append(value)
    answer_lst.append(child_lst4)
for ans in answer_lst:
    print(*ans)

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 ii in range(m):
	B.append(list(map(int,input().split())))
for k in range(n):
	ans = []
	for s in range(l):
		cul = 0
		for kk in range(m):
			cul += A[k][kk] * B[kk][s]
		ans.append(cul)
	ans = list(map(str,ans))
	print(" ".join(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)]
for u in range(n):
   for w in range(l):
     c=0 
     for z in range(m):
       c+=a[u][z]*b[z][w]
     if w==l-1:
       print(c)
     else:
       print(c,end=" ")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,m,l=list(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(m):
        for z in range(l):
            ans[x][z]+=A[x][y]*B[y][z]
for row in range(n):
    print("%d"%(ans[row][0]),end="")
    for col in range(1,l):
        print(" %d"%(ans[row][col]),end="")
    print()

Submission status: Accepted

Solution code:
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 = 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 = [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 = [[0 for i in range(m)] for j in range(n)]
#print(a)
b = [[0 for i in range(1)] for j in range(m)]
#print(b)
A=[]
B=[]
for j in range (n):
    a = [int(x) for x in input().split()]
    A.append(a)
#print(A)
for i in range(m):
    b = [int(y) for y in input().split()]
    B.append(b)
#print(B)
#print(A[1][1])
for j in range (0,n):
        F=[]
        #print(j)
        for k in range (0,l):
            S=0
            for i in range (0,m):
                B1=B[i][k]
                A1=A[j][i]
        #print(A1)
                #print(A1,B1,sep=" ")
                S=S+int(A1)*int(B1)
            F.append(S)
            #print(S,end='')
            #rint('@',end='')
        print(*F)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

for i in range(m):
    i = list(map(int, input().split()))
    B.append(i)
#積を求める

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(c)
    C.append(line)
#形式に合わせて出力する
for line in C:
    print(*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 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]=c[i][j]+a[i][k]*b[k][j]
for d in range(n):
    print(c[d][0],end="")
    for e in range(1,l):
        print(" %d"%c[d][e],end="")

    print()

Submission status: Accepted

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

A = [[0]*m]*n
B = [[0]*l]*m
#C = [[0]*l]*n エラーが起きてしまう
C = [[ 0 for x in range(l) ] for y in range(n)]

a = [[1, 2, 3], [4, 5, 6]]
a[1][1] = 7

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 ni in range(n):
    
    for li in range(l):
        C_count = 0
        for mi in range(m):
            C_count += A[ni][mi] * B[mi][li]
        C[ni][li] = C_count

for a in C:
    print(*a, sep=' ')

Submission status: Accepted

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

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

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

for i in range(m):
    lst = list(map(int,input().split()))
    for j in range(l):
        B[i][j] = lst[j]
        
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
    s = map(str, C[i])
    print(" ".join(s))

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

for line in C:
    print(*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 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:
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())
mat_a = [list(map(int, input().split())) for _ in range(n)]
mat_b = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    row = []
    for j in range(l):
        tmp = 0
        for k in range(m):
            tmp += mat_a[i][k]*mat_b[k][j]
        row.append(tmp)
    print(*row)

Submission status: Accepted

Solution code:
n,m,l = map(int,input().split())
A=[]
B=[]
for i in range(n):
    a = input().split()
    a_int= [int(s) for s in a ]
    A.append(a_int)
for j in range(m):
    b = input().split()
    b_int= [int(t) for t in b ]
    B.append(b_int)
i = 0
j = 0
Z = [[0 for q in range(l)] for p in range(n)]
for i in range(n):
    for t in range(l):
        z = 0
        for j in range(m):
            z += int(A[i][j])*int(B[j][t])
        Z[i][t]=z
i = 0
for i in range(n):
        print(' '.join(map(str,Z[i])))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m,l=map(int,input().split())
b=[]
for i in range(n):
    x= list(map(int, input().split()))
    b.append(x)
y=[]
for i in range(m):
    z= list(map(int, input().split()))
    y.append(z)
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[i][k] * y[k][j]
    print(*c[i])  #*をつけると[]が外れて表示される

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] * 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 = [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]
            
for i in range(len(c)):
    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)]

C=[]
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(c)
    C.append(line)
    
for line in C:
    print(*line)

Submission status: Accepted

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

for i in range(n):
    for j in range(l):
        for k in range(m):
            table[i][j] += matrix1[i][k] * matrix2[k][j]
for row in table:
    print(' '.join(map(str, row)))

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
#
# 7d
#

def main():
    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(*C[i])


if __name__ == '__main__':
    main()