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 =[int(r) for r in input().split()]

matrix = []
for ni in range(n):
    matrix.append([int(a)for a in input().split()])

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

for ni in range(n):

    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]

    print(sum)

Submission status: Accepted

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

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

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

for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]

    print(sum)

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
 
matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])
 
vector = []
for mi in range(m):
    vector.append(int(input()))
 
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]
 
    print(sum)

Submission status: Accepted

Solution code:

n, m = [int(i) for i in input().split()]
 
matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])
 
vector = []
for mi in range(m):
    vector.append(int(input()))
 
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]
 
    print(sum)

Submission status: Accepted

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

matrix = []
for ni in range(n):
   matrix.append([int(a) for a in input().split()])
   
vector = []
for mi in range(m):
    vector.append(int(input()))

b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
       sum += matrix[ni][mi] * vector[mi]
    
    print(sum)

Submission status: Accepted

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

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

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

b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]

    print(sum)

Submission status: Accepted

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

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

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



for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]


    print(sum)

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 j in range(m)]

for a_row in a:
	print(sum(a_row[k] * b[k] for k in range(m)))

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
 
matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])
 
vector = []
for mi in range(m):
    vector.append(int(input()))
 
b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]
 
    print(sum)

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
  
matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])
  
vector = []
for mi in range(m):
    vector.append(int(input()))
  
b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]
  
    print(sum)

Submission status: Accepted

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

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

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


b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]

    print(sum)

Submission status: Accepted

Solution code:
n,m=[int(x) for x in input().split()]
A=[[0 for i in range(m)] for i in range(n)]
vector=[0 for i in range(m)]
result=[0 for i in range(n)]
for i in range(n):
    A[i]=[int(x) for x in input().split()]
for i in range(m):
    vector[i]=int(input())
for i in range(n):
    for j in range(m):
        result[i] += A[i][j]*vector[j]
for _ in result:
    print(_)

Submission status: Accepted

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

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

for i in c:
    print(i)

Submission status: Accepted

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

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

for i in c:
    print(i)

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 _ in range(n):
    print(sum(a[_][i] * b[i] for i in range(m)))

Submission status: Accepted

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

n, m = map(int, raw_input().split())
t = [0] * m
mx = t * n
for i in xrange(n):
	mx[i] = map(int, raw_input().split())

v = [0] * m
for i in xrange(m):
	v[i] = input()

for i in xrange(n):
	t = 0
	for j in xrange(m):
		t += mx[i][j] * v[j]
	print t

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

Solution code:
n, m = map(int, raw_input().split())
A = [[0 for i in range(m)] for j in range(n)]
b = [0 for i in range(m)]
ans = [0 for i in range(n)]

for i in range(n):
    temp = map(int, raw_input().split())
    for j in range(m):
        A[i][j] += temp[j]
for i in range(m):
    b[i] = int(raw_input())
    
for i in range(n):
    for j in range(m):
        ans[i] += A[i][j]*b[j]
        
for i in range(n):
    print ans[i]

Submission status: Accepted

Solution code:
# ????????¨?????????????????????????±???????????????°??????
import sys

# ?¨??????\?????????????????????????????????
def read_data():
    n, m = [int(i) for i in sys.stdin.readline().strip().split(' ')]
    matrix = []
    for _ in range(n):
        matrix.append([int(num) for num in sys.stdin.readline().strip().split(' ')])

    vector = []
    for _ in range(m):
        vector.append(int(sys.stdin.readline().strip()))

    return matrix, vector

# ??????x????????????????¨????
def multiple(matrix, vector):
    n = len(matrix)
    m = len(vector)
    ans = []

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

        ans.append(sum)

    return ans

# ???????????¢??°
def main():
    matrix, vector = read_data()
    ans = multiple(matrix, vector)
    for i in ans:
        print(i)
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m = list(map(int,input().split()))
A = [map(int,input().split()) for i in range(n)]
b = [int(input()) for i in range(m)]
for a in A:
    print(sum([x*y for (x,y) in zip(a,b)]))

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

i = 0
while i < n:
    l = list(map(int, input().split()))
    A[i] = l
    i += 1

i = 0
while i < m:
    l = int(input())
    b[i] = l
    i += 1

i = 0
j = 0
while i < n:
    while j < m:
        c[i] += A[i][j] * b[j]
        j += 1
    i += 1
    j = 0

for i in c:
    print(i)

Submission status: Accepted

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

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

for i in range(n):
 c = 0
 for s in range(m):
  c += M1[i][s] * M2[s]
 print(c)

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

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

Submission status: Accepted

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


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

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

Submission status: Accepted

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

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())
matrix = []
vector = []
for _ in range(n):
    matrix.append(map(int, input().split()))
for _ in range(m):
    vector.append(int(input()))
for row in matrix:
    product = 0
    for i, e in enumerate(row):
        product += e * vector[i]
    print(product)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
M = [map(int, input().split()) for _ in range(n)]
V = [int(input()) for _ in range(m)]
for r in M:
    print(sum(x*y for x, y in zip(r, V)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
matrix_a = [list(map(int, input().split())) for i in range(n)]
matrix_b = [int(input()) for i in range(m)]
for i in range(n):
    print(sum([x*y for (x,y) in zip(matrix_b,matrix_a[i])]))

Submission status: Accepted

Solution code:
#coding:utf-8
n,m=list(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(int(input()))

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

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N, M = map(int, raw_input().split())
A = [map(int, raw_input().split()) for _ in xrange(N)]
B = [int(raw_input()) for _ in xrange(M)]
    
for i in xrange(N):
    print sum(a*b for a, b in zip(A[i], B))

Submission status: Accepted

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

for ai in a:
  print(sum([a_c * b_c for a_c, b_c in zip(ai, b)]))

Submission status: Accepted

Solution code:
[n, m] = [int(x) for x in raw_input().split()]
A = [[0] * m for x in range(n)]
B = [0] * m
counter = 0
while counter < n:
    A[counter] = [int(x) for x in raw_input().split()]
    counter += 1

counter = 0
while counter < m:
    B[counter] = int(raw_input())
    counter += 1

counter = 0
while counter < n:
    result = 0
    for j in range(m):
        result += A[counter][j] * B[j]
    print(result)
    counter += 1

Submission status: Accepted

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

counter = 0
while counter < n:
    A.append([int(x) for x in raw_input().split()])
    counter += 1

B = [int(raw_input()) for j in range(m)]

counter = 0
while counter < n:
    result = 0
    for j in range(m):
        result += A[counter][j] * B[j]
    print(result)
    counter += 1

Submission status: Accepted

Solution code:
n, m = [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(m)]
c = [0 for i in range(n)]
for s in range(0,n):
    a[s] = [int (x) for x in input().split(' ')]
for s in range(0,m):
    b[s] = int(input())
for s in range(0,n):
    for t in range(0,m):
        c[s] += a[s][t] * b[t]
for t in range(0,n):
    print("%d" % c[t])

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)]
ans = [0 for _ in range(n)]
for i in range(n):
    for j in range(m):
        ans[i] += a[i][j]*b[j]
print("\n".join(map(str, ans)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    # ??????A?????\???
    matrix = []
    matrix_size = [int(x) for x in input().split(' ')]
    for i in range(matrix_size[0]):
        matrix.append([int(x) for x in input().split(' ')])

    # ???????????????b?????\???
    vector_b = []
    for i in range(matrix_size[1]):
        vector_b.append(int(input()))

    # ??????
    result = []
    for i in range(matrix_size[0]):
        row = []
        for x, y in zip(matrix[i], vector_b):
            row.append(x*y)
        result.append(row)

    # ???????????????
    for r in result:
        print(sum(r))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [[0] * m for i in range(n)]
b = [0] * m
c = [0] * n
# read matrix A
for i in range(n):
    w = list(map(int, input().split()))
    for j in range(m):
        a[i][j] = w[j]
# read vevtor b
for j in range(m):
    b[j] = int(input())
# Ab -> c
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]
# output c
for i in range(n):
    print(c[i])

Submission status: Accepted

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

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

res=[]
for i in range(n):
	c=0
	for j in range(m):
		c+=mat[i][j]*vec[j]
	res.append(c)
for i in res:
	print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !
N, M = map(int, input().split())

A = []
b = []

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

v1 = [ list(map(int,input().split())) for i in range(n) ]
v2 = [ int(input()) for i in range(m) ]

for v in v1:
    print( sum([ v[i] * v2[i] for i in range(m) ]))

Submission status: Accepted

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

v1 = [ map(int,input().split()) for i in range(n) ]
v2 = [ int(input()) for i in range(m) ]

for v in v1:
    print(sum(map(lambda x,y:x*y,v,v2)))

Submission status: Accepted

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

v1 = [ input().split() for i in range(n) ]
v2 = [ int(input()) for i in range(m) ]

for v in v1:
    print(sum(map(lambda x,y:int(x)*y,v,v2)))

Submission status: Accepted

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

v1 = [ input().split() for _ in range(n) ]
v2 = [ int(input()) for _ in range(m) ]

for v in v1:
    print(sum(map(lambda x,y:int(x)*y,v,v2)))

Submission status: Accepted

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

v1 = [ input().split() for _ in range(n) ]
v2 = [ int(input()) for _ in range(m) ]

l = [sum(map(lambda x,y:int(x)*y,v,v2)) for v in v1 ]

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
mat = [map(int,input().split()) for i in range(n)]
vec = [int(input()) for i in range(m)]
for row in mat:
    print(sum([a*b for (a,b) in zip(row, vec)]))

Submission status: Accepted

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

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

for j in range(m):
    b[j] = 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 = list(map(int, input().split()))

a = [0]*n
b = [0]*m
c = [0]*n

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

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:
A = []
b = []

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

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

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

for i in range(n):
    print(sum([x*y for x,y in zip(A[i],b)]))

Submission status: Accepted

Solution code:
A = list()
b = list()

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

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

for i in range(m):
    b.append(list())
    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().strip().split())
a = [[0 for j in range(m)] for i in range(n)]
b = [[0] for j in range(m)]
c = [[0] for j in range(n)]

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

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


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

Submission status: Accepted

Solution code:
row, col = map(int,input().split())

mat = [[0 for i2 in range(col)] for i1 in range(row)]
for i in range(row):
    mat[i] = list(map(float,input().split()))
vec = [0 for i in range(col)]
for i in range(col):
       vec[i] = float(input())

result = [0 for i in range(row)]
for i in range(row):
    for j in range(col):
        result[i] += mat[i][j]*vec[j]

for i in range(len(result)):
    print(int(result[i]))

Submission status: Accepted

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

matrix = [[int(i) for i in input().split()] for gyo in range(n)]
vector = [[int(i) for i in input().split()] for gyo in range(m)]

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


for i in range(n):
    seki = 0
    for j in range(m):
        seki += int(matrix[i][j]) * int(vector[j][0])
    ans[i] = seki


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

Submission status: Accepted

Solution code:
'''
ITP-1_6-D
 ??????????????¨????????????
n??mn??m  ????????? AA ??¨???m??1m??1 ??????????????????bb ??????????????????AA ??¨ bb ?????????????????????????????°????????????????????????????????????

?¬????????????? mm ????????°??????????????????????????? m??1m??1????????????????????¨???????????????

b=??????????????????b1b2:bm??????????????????
b=(b1b2:bm)
?¬????????????? nn ????????°??????????????????????????? mm ????¨?????????????????????? n??mn??m ???????????¨???????????????

A=??????????????????a11a21:an1a12a22:an2......:...a1ma2m:anm??????????????????
A=(a11a12...a1ma21a22...a2m::::an1an2...anm)
??????????????????????????????????????????????????°????????¨???????´???¨?????????m??1m??1 ?????????????????? bb ???????????? ii ?????????????´???? bi(i=1,2,...,m)bi(i=1,2,...,m)???n??mn??m ????????? AA ?????? n??mn??m ??????????´????????????????ii ??? jj ?????????????´???? aij(i=1,2,...,n,j=1,2,...,m)aij(i=1,2,...,n,j=1,2,...,m)??§??????????????????

n??mn??m????????? AA ??¨m??1m??1?????????????????? bb ????????????n??1n??1?????????????????? cc ??¨?????????cc ??? ii ?????????????´? cici ????¬?????????§??????????????????

ci=???j=1maijbj=ai1b1+ai2b2+...+aimbm
???Input
???????????? nn ??¨ mm ????????????????????§??????????????????????¶???? nn ???????????? AA ???????´? aijaij ???
?????????????????§??????????????????????¶???? mm ?????????????????? bb ???????´? bibi ?????????????????????????????????????????????
???Output
????????? nn ???????????????????????????????????? cc ???????´? cici ???????????????????????????????????????????????????
'''
n, m = [int(cnt0) for cnt0 in input().split()]
matrixData = []
for i in range(n):
    # append | result = result + [a]
    matrixData.append([int(cnt1) for cnt1 in input().split()])
    
vector = []
for cnt2 in range(m):
    vector.append(int(input()))
    
for cnt3 in range(n):
    outputValue = 0
    for cnt4 in range(m):
        outputValue += ((matrixData[cnt3][cnt4]) * (vector[cnt4]))
    print(outputValue)

Submission status: Accepted

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

A = []
b = []

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

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

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

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

Submission status: Accepted

Solution code:
import sys

lines = [line for line in sys.stdin]

n,m = map(int,lines[0].split())

A=[map(int,lines[1+r].split()) for r in range(n)]
b=[int(lines[1+n+r]) for r in range(m)]

ab = []
for r in A:
    ab.append(0)
    for (a,c) in zip(r,b):
        ab[-1] += a*c

for i in ab:
    print (i)

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 i in range(m):
    b[i] = 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]
    print(c[i])

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)]
[print(sum([j*k for j,k in zip(a[i],b)])) for i in range(n)]

Submission status: Accepted

Solution code:
import sys

def input_number():
    for i in range(n):
        adding=map(int,raw_input().split())
        A.append(adding)
    for i in range(m):
        adding=input()
        b.append(adding)

if __name__ == '__main__':
    n,m=map(int,raw_input().split())
    A=[]
    b=[]
    ans=[0 for i in range(n)]
    input_number()
    for i in range(n):
        for j in range(m):
            ans[i] += A[i][j] * b[j]
    for i in range(n):
        print ans[i]

Submission status: Accepted

Solution code:
#!usr/bin/env python3

import sys


def main():
    m, n = [int(col_row) for col_row in sys.stdin.readline().split()]
    matrix = [[0 for col in range(n)] for row in range(m)]
    vector = [0 for row in range(n)]

    for row in range(m):
        lst = [int(element) for element in sys.stdin.readline().split()]
        for col in range(n):
            matrix[row][col] += lst[col]

    for row in range(n):
        lst = [int(element) for element in sys.stdin.readline().split()]
        vector[row] += lst[0]

    for row in range(m):
        sum_of_row = 0
        for col in range(n):
            sum_of_row += matrix[row][col] * vector[col]
        print(sum_of_row)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!usr/bin/env python3

import sys


def init_matrix_vector():
    m, n = [int(col_row) for col_row in sys.stdin.readline().split()]
    matrix = [[0 for col in range(n)] for row in range(m)]
    vector = [0 for row in range(n)]

    for row in range(m):
        lst = [int(element) for element in sys.stdin.readline().split()]
        for col in range(n):
            matrix[row][col] += lst[col]

    for row in range(n):
        lst = [int(element) for element in sys.stdin.readline().split()]
        vector[row] += lst[0]

    return matrix, vector


def print_matrix_vector_multiplication_result(matrix, vector):
    for row in range(len(matrix)):
        sum_of_row = 0
        for col in range(len(vector)):
            sum_of_row += matrix[row][col] * vector[col]
        print(sum_of_row)


def main():
    matrix, vector = init_matrix_vector()
    print_matrix_vector_multiplication_result(matrix, vector)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

#fin = open("test.txt", "r")
fin = sys.stdin

n, m = map(int, fin.readline().split())

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

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

for i in range(m):
	b[i] = int(fin.readline())

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 = []
b = []
for i in range(n):
    A.append([int(j) for j in input().split()])
for i in range(m):
    b.append(int(input()))
for i in range(n):
    sum = 0
    for j in range(m):
        sum += A[i][j]*b[j]
    print(sum)

Submission status: Accepted

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

Mat = []

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

b = []

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

c = [0 for k in range(n)]

for l in range(n):
	for l2 in range(m):
		c[l] += (Mat[l][l2] * b[l2])
	print(c[l])

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
A = []
for i in range(n):
    a = [int(j) for j in input().split()]
    A.append(a)
b = []
count = 0
while count < m:
    b.append(int(input()))
    count += 1


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 =[[int(i) for i in input().split()] for j in range(n)]
b = []
for i in range(m):
    b.append(int(input()))
ans = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        ans[i] += A[i][j]*b[j]
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
def matrics_vector_multiply(l1, l2):
    """
    l1: a list(matrics n*m)
    l2: a list(vector  m*1)
    returns a list(vector n*1)

    >>> matrics_vector_multiply([[2]], [0])
    [0]
    >>> matrics_vector_multiply([[1,2,0,1],[0,3,0,1],[4,1,1,0]], [1,2,3,0])
    [5, 6, 9]
    """
    result = []
    for row in l1:
        c = 0
        for i in range(len(row)):
            c += row[i] * l2[i]
        result.append(c)

    return result

if __name__ == '__main__':

    (row, col) = [int(i) for i in input().split(' ')]
    m = []
    v = []
    for r in range(row):
        elms = [int(i) for i in input().split(' ')]
        m.append(elms)
    
    for c in range(col):
        v.append(int(input()))

    for elm in matrics_vector_multiply(m, v):
        print(str(elm))

Submission status: Accepted

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

A = [ [ int(a) for a in input().split() ] for i in range(n) ]
B = [ [ int(b) for b in input().split() ] for i in range(m) ]
C = [ [ 0 for i in range(l) ] for i in range(n) ]

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

    print(" ".join([str(_) for _ in C[i]]))

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

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:
N,M = map(int, input().split())
A = []
for i in range(N):
    I = list(map(int, input().split()))
    A.append(I)

b = []
for i in range(M):
    bi = []
    I = int(input())
    bi.append(I)
    b.append(bi)

for i in range(N):
    result = 0
    for j in range(M):
        result += A[i][j] * b[j][0]
    print(result)

Submission status: Accepted

Solution code:
line = int(input().split(" ")[0])
a_vec =[]
b_vec =[]
res = []



for i in range(line):
    #a_vec.append([int(x) for x in a_input[i].split(" ")])
    a_vec.append([int(x) for x in input().split(" ")])


for i in range(len(a_vec[0])):
    b_vec.append(int(input()))

for a_row in a_vec:
    c = 0
    for i, a_col in enumerate(a_row):
        c += a_col * b_vec[i]
    res.append(c)

for r in res:
    print(r)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
gyoretu = [[0 for i in range (m)] for j in range(n)]
vector = [] #?¨?????????????
vector2 = [0 for i in range(n)] #?¨?????????????

for i in range(n):
	#for j in range(m):
	gyoretu[i] = input().split()
	#print(gyoretu[i][1])

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

#calculate
for i in range(n):
	for j in range(m):
		vector2[i] += int(gyoretu[i][j])*int(vector[j])

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

Submission status: Accepted

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

for k in range(n):
    for l in range(m):
        output[k] += A[k][l] * b[l]

for o in range(n):
    print(output[o])