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(x) for x in input().split())
matrix = []
vector = []

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

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

ans_vector = []

for line in matrix:
    sum = 0
    for i in range(m):
        sum += line[i] * vector[i]
    
    ans_vector.append(sum)

for ans in ans_vector:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
matrix = []
for _ in range(n):
    matrix.append(list(map(int, input().split())))
    
vec = []
for _ in range(m):
    vec.append(int(input()))
    
for row in matrix:
    s = 0
    for x in zip(row, vec):
        s += x[0] * x[1]
        
    print(s)

Submission status: Accepted

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

Submission status: Accepted

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

A = []
b = []
c = [0 for i in range(n)]

# input A
for _ in range(n):
    a = list(map(int, input().split()))
    A.append(a)
# input b
for _ in range(m):
    b.append(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:
n, m = [int(x) for x in input().split()]
a = []
b = []
for i in range(n): a.append([int(x) for x in input().split()])
for j in range(m): b.append(int(input()))
for a_row in a:
    print(sum([x * y for x, y in zip(a_row, b)]))

Submission status: Accepted

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

n = int(n)
m = int(m)

A = [[0]*m for a in range(n)]
count = 0
while n != 0:
    A[count] = list(map(int,input().split()))
    count += 1
    n -= 1

B = []
while m != 0:
    B.append(int(input()))
    m -= 1

output = []
for a in A:
    temp = [x * y for (x,y) in zip(a,B)]
    output.append(sum(temp))

for a in output:
    print(a)

Submission status: Accepted

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

list_b=[]                
for j in range(m):
    t=int(input())
    list_b.append(t)
    
sum_ab=0
list_ab=[]    
for i in range(n):
    for j in range(m):
        sum_ab+=list_mat[i][j]*list_b[j]
    list_ab.append(sum_ab)
    sum_ab=0
[print(i) for i in list_ab]

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)]
i = 1
while i <= n:
    row = list(map(int,input().split()))
    a[i-1] = row
    i +=1

i = 1
while i <= m:
    bi = int(input())
    b[i-1] = bi
    i+=1

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

Submission status: Accepted

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

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

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

for i in range(n):
    s = 0
    for j in range(m):
        s += x[i][j] * y[j]
    print(s)

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 j in range(m)]
for i in range(n):
    print(sum([x*y for (x, y) in zip(A[i], b)]))

Submission status: Accepted

Solution code:
x, y = map(int,input().split())
m = []
r = []
while x > 0:
  m.append(list(map(int,input().split())))
  x -= 1
while y > 0:
  r.append(int(input()))  
  y -= 1
for i in range(len(m)):
  result = 0
  for j in range(len(r)):
    result +=  m[i][j] * r[j]
  print(result)

Submission status: Accepted

Solution code:
from sys import stdin

n,m = map(int, stdin.readline().split())
A = []
for _ in range(n):
    inputlist = list(map(int, stdin.readline().split()))
    A.append(inputlist)
B = []
for _ in range(m):
    inputnum = int(stdin.readline())
    B.append(inputnum)

for row in range(n):
    num = 0
    for column in range(m):
        num += A[row][column] * B[column]
    print(num)

Submission status: Accepted

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


A =[]

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

B =[]

for x in range(m):
    B.append(int(input()))

#print(A)
#print(B)

ans = 0
for x in range(n):
  for y in range(m):
    ans += A[x][y]*B[y]
  print(ans)
  ans = 0

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = []
B = []
c = 0
for i in range(N):
  A.append([int(x) for x in input().split()])
  
for j in range(M):
  b = int(input())
  B.append(b)
  
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 n in range(N):
    a.append(list(map(int, input().split())))
    
c = [int(input()) for n in range(M)]

for n in range(N):
    res = 0
    for m in range(M):
        res += a[n][m] * c[m]
    print(res)

Submission status: Accepted

Solution code:

n, m = 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(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)]

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

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

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

for row in range(n):
    ans = 0
    for col in range(m):
        ans += a[row][col]*b[col]
    print(ans)

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    A = [[0] * m for i in range(n)]
    B = [0] * m
    C = [0] * 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):
        sum = 0
        for j in range(m):
            sum += A[i][j] * B[j]
        C[i] = sum
    for i in C:
        print(f"{i}")
    return 0


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
n_m_matrix = [list(map(int, input().split())) for _ in range(n)]
m_1_matrix = [int(input()) for _ in range(m)]
answer = []
for row in n_m_matrix:
    tmp = 0
    for i in range(m):
        tmp += row[i] * m_1_matrix[i]
    answer.append(tmp)

[print(n) for n in answer]

Submission status: Accepted

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

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

b = [0]*m

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

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

NMmatrix = []

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

Bmatrix = []

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

ans = []
    
for k in range(n):
    SUM = 0
    for l in range(m):
        SUM += NMmatrix[k][l]*Bmatrix[l]
    ans.append(SUM)

for disp in range(len(ans)):
    print(ans[disp], end='\n')

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
tableA= [[] for j in range(N)]
tableB = []

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

for i in range(M):
    tableB.append(int(input()))
    
for i in range(N):
    answer = 0
    for j in range(M):
        answer += tableA[i][j] * tableB[j] 
    print(f"{answer}")

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

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 = [map(int,input().split()) for _ in range(N)]
B = [int(input()) for _ 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())

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

vector = list()
for i in range(m):
  vector.append(int(input()))

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

[print(result[i]) for i in range(n)]

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [0for i 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())

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=[list(map(int,input().split()))for _ in[0]*n]
b=[int(input())for _ in[0]*m]
for a in A:print(sum(int(x)*int(y)for x,y in zip(a,b)))

Submission status: Accepted

Solution code:
n, m = 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()))
res = []
for i in range(n):
  value = 0
  for j in range(m):
    value += A[i][j] * B[j]
  print(value)

Submission status: Accepted

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

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

y = []
ans = 0
for i in range(k):
    b = int(input())
    y.append(b)

for i in range(n):
    ans = 0
    for v in range(k):
        ans = ans + x[i][v] * y[v]
    print(ans, end='\n')

Submission status: Accepted

Solution code:
n, m = 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(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)]
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 = [[] for i in range(N)]

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

B = [[0]*1 for i in range(M)]

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


for row in range(N):
    answer = 0
    for col in range(M):
        answer += A[row][col]*B[col]
    print("{}".format(answer))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
matrics = [[0 for i in range(0, m)] for j in range(0, n)]
vectors = [[0 for i in range(0, 1)] for j in range(0, m)]
# print(matrics)
# print(vectors)
for i in range(0, n):
	matrics[i] = list(map(int, input().split()))
for i in range(0, m):
	vectors[i] = int(input())
# print(matrics)
# print(vectors)
for i in matrics:
	sum = 0
	for j in range(0, m):
		sum = sum + i[j] * vectors[j]
	print(sum)

Submission status: Accepted

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

C = []

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

Submission status: Accepted

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

count = 0
while count < i:
    x = input()
    x = [s for s in map(int, x.split())]
    a.append(x)    
    count += 1

count = 0
while count < j:
    x = input()
    x = [s for s in map(int, x.split())]
    b.append(x)
    count += 1

# print('###################')
for x in range(i):
    for y in range(j):
        c += a[x][y] * b[y][0]
    print(c)
    c = 0

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

vec_A = [[] for i in range(n)]
for i in range(n):
    vec_A[i] = list(map(int, input().split()))
    
vec_b = [[0]*1 for i in range(m)]
for i in range(m):
    vec_b[i] = int(input())
    
for row in range(n):
    tmp = 0
    for col in range(m):
        tmp += vec_A[row][col] * vec_b[col]
    print('{}'.format(tmp))

Submission status: Accepted

Solution code:
# n, m = [int(x) for x in input().split()]
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)]
# b = []

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

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

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

Submission status: Accepted

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

for i in range(n):
    a.append([int(s) for s 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:
def Calc(a,b,m):
    prod=0
    for i in range(m):
        prod=prod+a[i]*b[i]
    return prod


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

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

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

for i in range(n):
    print(Calc(A[i],b,m))

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 j in range(M):
    B.append(int(input()))
for k in range(N):
    p=0
    for z in range(M):
        p+=A[k][z]*B[z]
    print(p)

Submission status: Accepted

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

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

for num_a in a:
    cnt = 0
    result = 0
    for i in num_a:
        result+=i*b[cnt]
        cnt+=1
        
    print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for _ in range(m):
    e = int(input())
    b.append(e)
    
for row in a:
    sum = 0
    for i in range(m):
        sum += row[i] * b[i]
    print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

A_list = []
B_list = []

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

for j in range(m):
    B = int(input())
    B_list.append(B)

for l in range(n):
    answer = 0
    for k in range(m):
        answer += (A_list[l][k] * B_list[k])
    print(answer)

Submission status: Accepted

Solution code:
row , column = map(int,input().split())
b = [[0]*column for i in range(row)]

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

for i in range(column):
    a= int(input())
    for j in range(row):
        b[j][i] *= a
    
for i in range(row):
    print(sum(b[i]))
#print(sum([row-1]),end="")

Submission status: Accepted

Solution code:
base_num = input()
unit = base_num.split(' ')
vec_a_max = int(unit[0])
vec_b_max = int(unit[1])
end_num = 0

input_list = []
while True:
    base_suit = input()
    input_list.append(base_suit)

    end_num += 1
    if (vec_a_max + vec_b_max) == end_num:
        break

matrix_a = []
matrix_b = []
for i, r in enumerate(input_list):
    if i < vec_a_max: 
        row = r.split(' ')
        matrix_a.append([int(x) for x in row])
    else:
        matrix_b.append(int(r))

for row_a in matrix_a:
    c = 0
    for a,b in zip(row_a,matrix_b):
        c += a * b
    print(c)

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):
    cnt = 0
    for j in range(M):
        cnt += A[i][j] * B[j]
    print(cnt)

Submission status: Accepted

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

b_list = list()
for i in range(m):
    b_list.append(int(input()))

import operator
for a_row in a_list:
    print(sum(list(map(operator.mul, a_row, b_list))))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
mat = []
i = 0
while True:
    tmp = list(map(int, input().split()))
    mat.append(tmp)
    i += 1
    if i == n:
        break

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
data = list(map(int,input().split())) #行列の型
matlix = [list(map(int,input().split()))for i in range(data[0])]
#print(matlix)
vector =[]
for j in range(data[1]):
    vector.append(int(input()))
#print(vector)
#answer=[]
for k in range(0,data[0]):
    num=0
    
    for l in range(0,data[1]):
        num += matlix[k][l]*vector[l]
    print(num)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
A=[0 for s in range(n)]
B=[]
sum=0
for l in range(n):
    A[l]=list(map(int,input().split()))
for k in range(m):
    B.append(int(input()))
for w in range(n):
    for t in range(m):
        sum+=A[w][t]*B[t]
    print(sum)
    sum=0

Submission status: Accepted

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

    for row in range(N):
        tmp = 0
        for col in range(M):
            tmp += A[row][col]*B[col]
        print("%d" % (tmp))

if __name__ == '__main__':
  main()

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

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

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

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


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

Submission status: Accepted

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

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

Submission status: Accepted

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

table = [0] * m
column = []

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

for j in range(n):
	column.append(int(input()))

for k in range(m):
	result = 0
	for l in range(n):
		result += table[k][l] * column[l]
	print(result)

Submission status: Accepted

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

c_m = 0
c_v = 0

matrix =[]
vector = []

ans = []

while c_m < n:
    matrix.append([int(n) for n in input().split()])
    c_m += 1

while c_v < m:
    vector.append(int(input()))
    c_v += 1

for N in range(n):
    a = 0
    for M in range(m):
        a += matrix[N][M]*vector[M]

    ans.append(a)

for a in ans:
    print(a)

Submission status: Accepted

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

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

for v in B:
    print(v)

Submission status: Accepted

Solution code:
from functools import reduce

n, m = list(map(lambda x: int(x), input().split()))

matrix_strings = []

for _ in range(n):
    matrix_strings.append(input())

vector_strings = []

for _ in range(m):
    vector_strings.append(input())

matrix = list(map(
    lambda matrix_string: list(map(
        lambda num_str: int(num_str),
        matrix_string.split())),
    matrix_strings))

vector = list(map(lambda num_str: int(num_str), vector_strings))

dot_product = []

for matrix_row in matrix:
    dot_product.append(
        reduce(
            lambda acc, m_ij_and_v_i: acc + (m_ij_and_v_i[0] * m_ij_and_v_i[1]),
            zip(matrix_row, vector),
            0)
    )

for dot_product_i in dot_product:
    print(dot_product_i)

Submission status: Accepted

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

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

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

# calculate

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

Submission status: Accepted

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

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


for i in range(n):
    y = int(input())
    b.append(y)

    
for i in range(m):
    ans = 0
    for j in range(n):
        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 i in range(n)]
b=[int(input()) for i in range(m)]

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

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

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

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

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

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

Submission status: Accepted

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

print(*[sum([i * j for i, j in zip(A[i], b)]) for i in range(m)], sep="\n")

Submission status: Accepted

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

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

b = [int(input()) for _ in range(M)]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = [int(n) for n in input().split()]
A = [[int(n) for n in input().split()] for _ in range(N)]
B = [int(input()) for _ in range(M)]
[print(sum([x*y for x,y in zip(a, B)])) for a in A]

Submission status: Accepted

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

A=[list(map(int,input().split())) for _ in [None]*n]
b=[int(input()) for _ in [None]*m]
for a in A:print(sum(i*j for i,j in zip(a,b)))

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

Submission status: Accepted

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

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

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:
n, m = 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(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())

M = []
for i in range(1, n+1):
    row = list(map(int, input().split()))
    M.append(row)
# print(M)
v = []
for i in range(1, m+1):
    v.append(int(input()))
# print(v)

def dot_vec(vec1, vec2):
    # print(vec1, vec2)
    return sum(
        e1 * e2 for e1, e2 in zip(vec1, vec2)
    )

ans = [
    dot_vec(row, v) for row in M
]

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a_list = []
for i in range(n):
	a_list.append(list(map(int, input().split())))
b_list = []
for i in range(m):
	b_list.append(int(input()))
for a_rows in a_list:
	x_list = []
	index = 0
	for a in a_rows:
		x_list.append(a*b_list[index])
		index += 1
	print(sum(x_list))