Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Matrix Vector Multiplication

Write a program which reads a $ n \times m$ matrix $A$  and a $m \times 1$ vector $b$, and prints their product $Ab$.

  A column vector with m elements is represented by the following equation.

\[
  b = \left(
    \begin{array}{c}
      b_1  \\
      b_2  \\
      : \\ 
      b_m \\ 
    \end{array}
  \right)
\]

  A $n \times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.

\[
  A = \left(
    \begin{array}{cccc}
      a_{11} & a_{12} & ... & a_{1m} \\
      a_{21} & a_{22} & ... & a_{2m} \\
       :    &   :   &  :  &  : \\
      a_{n1} & a_{n2} & ... & a_{nm} \\
    \end{array}
  \right)
\]

  $i$-th element of a $m \times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$  $j = 1, 2, ..., m$).

The product of a $n \times m$ matrix $A$ and a $m \times 1$ column vector $b$ is a $n \times 1$ column vector $c$, and $c_i$ is obtained by the following formula:

\[
c_i = \sum_{j=1}^m a_{ij}b_j  = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m
\]

Input

  In the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.

Output

  The output consists of $n$ lines. Print $c_i$ in a line.

Constraints

$1 \leq n, m \leq 100$

$0 \leq b_i, a_{ij} \leq 1000$

Sample Input

3 4
1 2 0 1
0 3 0 1
4 1 1 0
1
2
3
0

Sample Output

5
6
9



Sample input:
3 4
1 2 0 1
0 3 0 1
4 1 1 0
1
2
3
0


Sample output:
5
6
9

Submission status: Accepted

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

for i in range(n):
	num = 0
	for j in range(m):
		num += bec1_list[i][j] * bec2_list[j][0]
	print(str(num))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
matrix_a = [[0 for i in range(m)]for j in range(n)]
matrix_b = [0]*m
matrix_c = [0]*n

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

for i in range(m):
    matrix_b[i] = int(input())
        
for i in range(n):
    for j in range(m):
        matrix_c[i] += matrix_a[i][j] * matrix_b[j] 
    print(matrix_c[i])

Submission status: Accepted

Solution code:
#行列のインプットdata挿入
list_xy = list(map(int, input().split()))

#初期リストの作成
list_A = [[0 for i in range(list_xy[1])] for j in range(list_xy[0])]
list_b = list()
result = list()
#print(list_A)
#print(list_b)

#リストへインプットdata挿入
for i in range(list_xy[0]):
    input_temp = list(map(int, input().split()))
    for j in range(list_xy[1]):
        list_A[i][j] = input_temp[j]
#print(list_A)

for i in range(list_xy[1]):
    list_b.append(int(input()))
#print(list_b)

#計算実施
for i in range(list_xy[0]):
    result_temp = 0
    for j in range(list_xy[1]):
        result_temp += list_A[i][j] * list_b[j]
    result.append(result_temp)
#print(result)

#計算結果の表示
for i in range(len(result)):
    print(result[i])

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
    n, m = 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 = 0
        for j in range(m):
            ans += A[i][j] * b[j][0]
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,m = list(map(int, input().split() ))
A= [[0 for i in range(m)] for j in range(n)] 
b = [0 for i in range(m)]
for ni in range(n):
 A[ni] = list( map(int,input().split() ))
for mi in range(m):
 b[mi] = int(input());

for i in range(n):
 ai = 0;
 for mi in range(m):
  ai = ai + A[i][mi]*b[mi];
 print(ai)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
A = [[] for i in range(n)]
b = []
for i in range(n):
    *Ai, = map(int, input().split())
    A[i] = Ai
for j in range(m):
    b.append(int(input()))
for i in range(n):
    print(sum([A[i][j]*b[j] for j in range(m)]))

Submission status: Accepted

Solution code:
queue=[]
b=[]

list_s=[int(i) for i in input().split()]

for w in range(list_s[0]):
    list_1=[int(i) for i in input().split()]
    queue.append(list_1)

for i in range(list_s[1]):
    b.append(int(input()))

for n in range(list_s[0]):
    ans=0
    for q in range(list_s[1]):
        ans=ans+(queue[n][q]*b[q])
        
    print(ans)

Submission status: Accepted

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

#ベクトルの初期化
A = [[] for i in range(n)]
b = [0 for i in range(m)]
#答えのベクトル
ans = [0 for i in range(n)]

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

for i in range(m):
    b[i] = int(input())

for i in range(n):
    for j in range(m):
        ans[i] += A[i][j] * b[j]

for val in ans:
    print(val)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
c=[]
d=[]
for i in range(a):
    c.append(list(map(int,input().split())))
for j in range(b):
    d.append(list(map(int,input().split())))
#length = len(d[1][0])

ff=[]
for i in range(a):
    f=0
    for j in range(b):
       f += (int(c[i][j])*int(d[j][0]))
    ff.append(f)
    
for i in range(len(ff)):
    print(ff[i])

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [int(input()) for i in range(m)]
ans = []
for a in A:
    vec = 0
    for i in range(m):
        vec += a[i] * B[i]
    ans.append(vec)
print("\n".join(map(str, ans)))

Submission status: Accepted

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

arrs = []

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

vector = []
for _ in range(m):
    scalar = int(input())
    vector.append(scalar)

for arr in arrs:
    c = 0
    for i in range(len(arr)):
        c += arr[i] * vector[i]
    print(c)

Submission status: Accepted

Solution code:
n,m=(int(x) for x in input().split())
a=[]
for i in range(n):
  aa=list(map(int,input().split()))
  a.append(aa)
b=[]
for i in range(m):
  bb=int(input())
  b.append(bb)
c=[]
for i in range(n):
  ci=0
  for j in range(m):
    cie=a[i][j]*b[j]
    ci+=cie
  c.append(ci)
for i in range(len(c)):
  print(c[i])

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
mat = [[0 for i in range(m)] for j in range(n)]
vec = [0 for i in range(m)]

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

for i in range(m):
    vec[i] = int(input())

for i in range(n):
    a = 0
    for j in range(m):
        a += mat[i][j]*vec[j]
    print(a)

Submission status: Accepted

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

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

res = [0 for i in range(n)]

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

for i in range(n):
    print(res[i])

Submission status: Accepted

Solution code:
n,m=list(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(int(input()))
for i in range(n):
    s=0
    for j in range(m):
        s+=a[i][j]*b[j]
    print(s)

Submission status: Accepted

Solution code:

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

b = []
for _ in range(collumn):
    b.append(int(input()))

# けいさん
for r in range(row):
    sum = 0
    for c in range(collumn):
        sum += A[r][c] * b[c]
    print(sum)

Submission status: Accepted

Solution code:
# nとmを受け取る
n, m = map(int, input().split())

# Aを受け取る
a = [input().split() for i in range(n)]

# bを受け取る
b = [input() for j in range(m)]

# 処理実行
for k in range(n):
    # 行ごとにアウトプット用の変数を初期化
    output = 0
    for l in range(m):
        output = output + int(a[k][l]) * int(b[l])
    print(output)

Submission status: Accepted

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

ans = [0] * n

for i in range(n):
    res = 0
    for a, b in zip(matrix[i], vector):
        res += a * b
    ans[i] = res

print(*ans, sep="\n")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

b = []
for j in range(c):
    b.append(int(input()))

for i in range(r):
    inner = 0
    for j in range(c):
        inner += A[i][j] * b[j]
    print(inner)

Submission status: Accepted

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

#n x m の行列を読み込む
A = [[int(i) for i in input().split()]for j in range(n)]

#m x 1 の行列を読み込む
b = [int(input()) for i in range(m)]
for i in range(n):
    ci = 0
    for j in range(m):
         ci += A[i][j] * b[j]
    c.append(ci)

for i in range(n):
    print(c[i])

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
M = [list(map(int, input().split())) for i in range(n)]
V = [int(input()) for j in range(m)]
for i in range(n): print(sum([M[i][j]*V[j] for j in range(m)]))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
A = [[0 for i in range(m)] for j in range(n)]
b = [0 for i in range(m)]
c = [0 for i in range(n)]
for i in range(n):
    A_tmp = input().split()
    for j in range(m):
        A[i][j] = int(A_tmp[j])
for k in range(m):
    b[k] = int(input())
for i in range(n):
    for j in range(m):
        c[i] = c[i] + A[i][j] * b[j]
    print(c[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def calc_matrix_product(M, x, row, col):

    #res = list()

    for r in range(row):
        s = 0
        for c in range(col):
            s += M[r][c] * x[c]
        print(str(s))
        #res.append(s)
        # if r != row - 1:
        #     print(str(s))
        # else:
        #     print(str(s), end="")
        #     print("\n")


if __name__ == "__main__":
    param = input().split(" ")
    row = int(param[0])
    col = int(param[1])

    # create matrix
    M = list()
    r = row

    while(r > 0):

        param = input().split(" ")
        M.append([ int(a) for a in param ])

        r = r - 1

    #create vector
    c = col
    x = list()

    while( c > 0 ):

        param = input()

        x.append(int(param))

        c = c - 1

    calc_matrix_product(M, x, row, col)

Submission status: Accepted

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

A = [[0 for i in range(m)]for j in range(n)]
B = [0 for i in range(m)]
Anser = [0 for i in range(n)]

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

for i in range(m):
    B[i] = int(input())

for i in range(n):
    for j in range(m):
        Anser[i] += A[i][j]*B[j]
    print(Anser[i])

Submission status: Accepted

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

for i in range(n):
    r = 0
    for k,l in zip(mat[i],vec):
        r += k*l
    print(r)

Submission status: Accepted

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

Submission status: Accepted

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

for j in range(m):
    b.append(int(input()))

ans=[]
for i in range(n):
    ai=a[i]
    ansi=0
    for j in range(m):
        ansi+=ai[j]*b[j]
    ans.append(ansi)

for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
i, j = map(int,input().split())
a = []
b = []
result = 0
for _ in range(i):
    a.append([row for row in map(int, input().split())])
for _ in range(j):
    b.append(int(input()))
for row in range(i):
    for col in range(j):
        result += a[row][col] * b[col]
    print(result)
    result = 0

Submission status: Accepted

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


list1 = [[0]*m for i in range(n)]
list2 = [0]*m

for i in range(n):
    list = input().split()
    for j in range(m):
        list1[i][j]=int(list[j])
for j in range(m):
    list2[j] = int(input())

sum = [0]*n
for i in range(n):
    for j in range(m):
        sum[i] += list1[i][j] * list2[j]
for i in range(n):
    print(sum[i])

Submission status: Accepted

Solution code:
matrixA = []
matrixB = []
resultC = []
n, m = map(int, input().split())
for i in range (n):
    matrixA.append(list(map(int, input().split())))
for i in range (m):
    matrixB.append(int(input()))
for i in range (n):
    num = 0
    for j in range (m):
        num += matrixA[i][j]*matrixB[j]
    resultC.append(num)
for i in range (n):
    print(resultC[i])

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split(" ")))
a_nm = [list(map(int, input().split(" "))) for i in range(n)]
b_nm = [int(input()) for k in range(m)]

for ab in a_nm:
    mul = 0
    for j in range(m):
        
        mul = mul + ab[j] * b_nm[j]
    print(mul)

Submission status: Accepted

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

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

for i in range(len(A)):
    Arc=[int(k) for k in A[i].split()]
    x=0
    for k in range(len(Arc)):
       x += Arc[k]*B[k]
    print(x)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
avec = [[0 for i in range(m)]for j in range(n)]
bvec = [0 for i in range(m)]
for i in range(n):
    nums = [int(e) for e in input().split()]
    for j in range(m):
        avec[i][j] = nums[j]
        
for i in range(m):
    bvec[i] = int(input())

for i in range(n):
    cvec = 0
    for j in range(m):
        cvec = cvec + (avec[i][j] * bvec[j])
    print(cvec)

Submission status: Accepted

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

for i in range(n):
    ci = 0
    for j in range(m):
        ci += A[i][j]*b[j]
    print(ci)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
listInf = input().split()
listInf[0] = int(listInf[0])
listInf[1] = int(listInf[1])
s = []
ans = []

a = [[0]*listInf[1] for _ in range(listInf[0])]
b = [0 for _ in range(listInf[1])]

for column in range(listInf[0]):
    oneOfA = input().split()
    for row in range(listInf[1]):
        a[column][row] = int(oneOfA[row])

for c in range(listInf[1]):
    b[c] = int(input())

for x in range(listInf[0]):
    for y in range(listInf[1]):
        s.append(a[x][y]*b[y])
    print(sum(s))
    s.clear()

Submission status: Accepted

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

a = []

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

b = []

for i in range(m):
  b.append(int(input()))

for i in range(n):
  print(sum([a[i][x] * b[x] for x in range(m)]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for j in range(m):
    b[j] = int(input())

for i in range(n):
    for j in range(m):
        Ab[i] += A[i][j] * b[j]

for i in range(n):
    print(Ab[i])

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
a = list()
for s in range(n):
    a.append(list(map(int, input().split())))
    
b = list()
for g in range(m):
    b.append(int(input()))

for ss in range(n):
    sum = 0
    for gg in range(m):
        sum += a[ss][gg] * b[gg]
    print(sum)

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    h,w=map(int,input().split())
    aa=[list(map(int,input().split())) for _ in range(h)]
    bb=[int(input()) for _ in range(w)]
    for ak in aa:
        ans=0
        for a,b in zip(ak,bb):
            ans+=a*b
        print(ans)

main()

Submission status: Accepted

Solution code:
n,m = [ int(s) for s in input().split() ]
  
v1 = [ [0] * m for i in range(n) ]
v2 = [0] * m

for i in range(n):
    v1[i] = [ int(s) for s in input().split() ]

for i in range(m):
    v2[i] = int(input())

for i in range(n):
    total = 0
    for j in range(m):
        total += v1[i][j] * v2[j]
    print(total)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
matrixA = [[0] * (m) for i in range(n)]
matrixB = [[0] for i in range(m)]
matrix = [[0] for i in range(n)]

for i in range(0, n):
    listnum = input().split()
    for j in range (0, m):
        matrixA[i][j] = listnum[j]

for i in range(0,m):
    matrixB[i][0] = input()

for i in range(0,n):
    s = 0
    for j in range(0,m):
        s = s+int(matrixA[i][j])*int(matrixB[j][0])
        matrix[i][0] = str(s)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
lst_1 = list(map(int, input().split()))
n, m = lst_1[0], lst_1[1]
lst = []
vec = []
for i in range(n):
    lst_2 = list(map(int, input().split()))
    lst.append(lst_2)

for i in range(m):
    num = int(input())
    vec.append(num)

for i in range(n):
    c = []
    for j in range(m):
        cj = lst[i][j] * vec[j]
        c.append(cj)
    print(sum(c))

Submission status: Accepted

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

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

for c in C:
    print(c)

Submission status: Accepted

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

A = []
for _ in range(n):
    A.append([int(i) for i in input().split()])
b = [int(input()) for _ in range(m)]
    
ans = []
for a in A:
    ans.append(sum([x * y for x, y in zip(a, b)]))

for a in ans:
    print(a)

Submission status: Accepted

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

print(*c, sep='\n')

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
amat = [[0 for i in range(m)] for j in range(n)]
bmat = [[0 for k in range(1)] for l in range(m)]
cmat = [[0 for x in range(1)] for y in range(n)]
for i in range(n):
 amat[i] = list(map(int, input().split()))
for j in range(m):
 bmat[j][0] += int(input())
for k in range(n):
 for l in range(m):
  cmat[k][0] += amat[k][l]*bmat[l][0]
 print(cmat[k][0])

Submission status: Accepted

Solution code:
n, m = 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(int(input()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = 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(int(input()))

sum = 0
    
for i in range(n):
    for j in range(m):
        sum += a[i][j]*b[j]
    print(sum)
    sum = 0

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
A = [[int(j) for j in input().split()] for i in range(n)]
for j in range(m):
    b = int(input())
    for i in range(n):
        A[i][j] *= b
        
for row in A:
    print(sum(row))

Submission status: Accepted

Solution code:
n, m = map(int, input().split(' '))
A = [[None for i in range(m)] for j in range(n)]
for i in range(n):
    table = list(map(int, input().split(' ')))
    for j in range(m):
        A[i][j] = table[j]

b = [None] * m
for i in range(m):
    b[i] = int(input())

c = [None] * n
for i in range(n):
    for j in range(m):
        if c[i] is None:
            c[i] = A[i][j] * b[j]
        else:
            c[i] += A[i][j] * b[j]

for item in c:
    print(item)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

b = [int(input()) for i in range(m)] 

for i in a:
    x = 0
    for k in range(m):
        x += i[k]*b[k]
    else:
        print(x)

Submission status: Accepted

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

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

b = []
for i in range(0,m):
    b.append(int(input()))
    #print(b)

c = []
for i in range(0,n):
    ci = 0
    for j in range(0,m):
        ci += a[i][j]*b[j]
    c.append(ci)
    print(ci)

Submission status: Accepted

Solution code:
n, m = map(int, input().split(" "))
A = []
b = []
ci = 0

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

for i in range(n):
    for j in range(m):
         ci += A[i][j]*b[j]
    print(ci)
    ci = 0

Submission status: Accepted

Solution code:
u,v=list(map(int,input().split()))
a=[[0]*v for j in range(u)]

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

b=[0 for i in range(v)]

for i in range(v):
    b[i]=int(input())

for i in range(u):
    c=0
    for j in range(v):
        c+=a[i][j]*b[j]
    print(c)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
matrix = []
for i in range(n):
    M = list(map(int, input().split()))
    matrix.append(M)
#print(matrix)
colum = []
for i in range(m):
    colum.append(int(input()))
#print(colum)

for i in range(n):
    sum = 0
    for j in range(m):
        sum += matrix[i][j] * colum[j]
        #print(matrix[i][j])
    print(sum)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
arr_a = []
vec_b = []
for x in range(0, n):
    arr_a.append(list(map(int, input().split())))
for y in range(0, m):
    vec_b.append(int(input()))

for ni in range(0, n):
    s = 0
    for mi in range(0, m):
        s += (arr_a[ni][mi] * vec_b[mi])
    print(s)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())

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

for i in range(M):
    bi = int(input())
    for j in range(N):
        A[j][i] *= bi

for i in range(N):
    print(sum(A[i]))

Submission status: Accepted

Solution code:
def get_matrix_size(x):
    row = len(x)
    col = len(x[0])
    return row, col

def get_matrix(x):
    row, col = get_matrix_size(x)
    for i in range(row):
        line = list(map(int, input().split()))
        if len(line) != col:
            break
        x[i] = line

def get_matrix_product(a, b):
    a_row, a_col = get_matrix_size(a)
    b_row, b_col = get_matrix_size(b)
    if a_col != b_row:
        return
    c_row = a_row
    c_col = b_col
    c = [[0 for j in range(c_col)] for i in range(c_row)]
    for i in range(c_row):
        for j in range(c_col):
            for k in range(a_col):
                c[i][j] += a[i][k] * b[k][j]    
    return c

n, m = map(int, input().split())
a = [[0 for j in range(m)] for i in range(n)]
b = [[0 for j in range(1)] for i in range(m)]
get_matrix(a)
get_matrix(b)
c = get_matrix_product(a, b)
for i in range(len(c)):
    print(c[i][0])

Submission status: Accepted

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

matrix = list()
vector = list()
result = list()

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

for i in range(n):
    vector.append(int(input()))
    
for j in range(m):
    suma = 0
    for i in range(n):
        suma += matrix[j][i] * vector[i]
    result.append(suma)

for s in result:
    print(s)

Submission status: Accepted

Solution code:
A, b, c = [], [], []
n, m = map(int, input().split())
for i in range(n):
    A.append([int(x) for x in input().split()])
for i in range(m):
    b.append(int(input()))
c = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        c[i] += A[i][j] * b[j]
for i in range(n):
    print(c[i])

Submission status: Accepted

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

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

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


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

	print(c)

Submission status: Accepted

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

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

for j in range(c):
    b.append(int(input()))
    
    
for j in range(r):
    q=0
    for i in range(c):
        q=q+a[j][i]*b[i]
    print("%d"%q)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
rows,cols=map(int,input().split(" "))
a=[[0 for i in range(cols)] for j in range(rows)]
b=[0 for col in range(cols)]
c=[0 for row in range(rows)]

for row in range(rows):
    a_val=list(map(int,input().split(" ")))
    for col in range(cols):
        a[row][col]=a_val[col]

for col in range(cols):
    b_val=int(input())
    b[col]=b_val

for row in range(rows):
    for col in range(cols):
        c[row]+=a[row][col]*b[col]

for row in range(rows):
    print(c[row])

Submission status: Accepted

Solution code:
rows, columns = map(int, (input().split()))

matrixA = list()
matrixB = list()

# create matrixA
for _ in range(rows):
    row = list(map(int, input().split()))
    matrixA.append(row)

# create matrixB    
for _ in range(columns):
    num = int(input())
    matrixB.append(num)

# calculation part
result = list()
for ir in range(rows):
    sum = 0
    for ic in range(columns):
        sum += matrixA[ir][ic] * matrixB[ic]
    result.append(sum)
    
# output result
for num in result:
    print(num)

Submission status: Accepted

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

for i in range(n):
    printsum = 0
    for j in range(m):
        printsum += array1[i][j] * array2[j]
    print(printsum)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
A = [[] for i in range(n)]
b = [0 for i in range(m)]
c = [0 for i in range(n)]
for i in range(n):
    A[i].extend(map(int,input().split()))
for i in range(m):
    b[i] = int(input())
for i in range(n):
    for j in range(m):
        c[i] += A[i][j] * b[j]
    print(c[i])

Submission status: Accepted

Solution code:
x,y=map(int,input().split())
A=list(list(map(int,input().split())) for i in range(x))
B=list(int(input()) for i in range(y))
ans=[]
for i in range(x):
    count=0
    for j in range(y):
        count +=A[i][j]*B[j]
    ans.append(count)
for i in range(len(ans)):print(ans[i])

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
a = []
for _ in range(n):
    a.append([int(i) for i in input().split()])
b = [int(input()) for _ in range(m)]
for li in a:
    print(sum([li[i] * b[i] for i in range(m)]))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a_mtx = []
for i in range(n):
    a_mtx.append(list(map(int, input().split())))
b_mtx = []
for j in range(m):
    b_mtx.append(int(input()))

c_mtx = []
for a in a_mtx:
    accu = 0
    for b, c in zip(a, b_mtx):
        accu += b*c
    c_mtx.append(accu)

for cc in c_mtx:
    print(cc)

Submission status: Accepted

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


for x in a:
    print(sum([v * w for v, w in zip(x, b)]))