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

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

Submission status: Accepted

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

for a in matrixA:
    c = 0
    for ai, b in zip(a, col_vecB):
        c += ai * b
    print(c)

Submission status: Accepted

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

matrixA = []
vectorB = []
c = [[0 for r in range(1)]for s in range(n)]
sums = 0


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

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


for index_row in range(len(matrixA)):
    for index_column in range(len(matrixA[index_row])):

        col_m1 = matrixA[index_row][index_column]
        col_m2 = vectorB[index_column]
        sums = sums + (col_m1*col_m2)
  
    c[index_row] = sums
    sums = 0

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

Submission status: Accepted

Solution code:
def main():
    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:
        ans = 0
        for i in range(m):
            ans += x[i] * b[i]
        print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

A = []
b = []
num = []
x = 0

for i in range(n):
    a = list(map(int, input().split()))    
    A.append(a)
    
for i in range(m):
    b.append(int(input()))
    
while x < n:
    for i in range(m):
        num.append(A[x][i] * b[i])
        
    x += 1
    
    print(sum(num))
    
    num = []

Submission status: Accepted

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

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

    print(sum_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 x in a:
    print(sum([v * w for v, w in zip(x, b)]))

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

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

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

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

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]

for i in c:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

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

y = [int(input()) for k in range(m)]

for l in range(n):
	t=0
	for o in range(m):
		t += x[l][o]*y[o]
	print(t)

Submission status: Accepted

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

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

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

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

b =[]

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

#print(list(n_m))
#print(list(b))

for n_s in n_m:
    out_put_plus =0
    for m_s, b_s in zip(n_s,range(m)):
        #print(m_s,end="×")
        #print(b[b_s])
        out_put_plus+= m_s * b[b_s]
    out_put.append(out_put_plus)
    
for out_put_no in out_put:
    print(out_put_no)

Submission status: Accepted

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
n, m = map(int, input().split())
a = getSomeInputListInt(n)
b = getSomeInputInt(m)

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

Submission status: Accepted

Solution code:
s = input().rstrip().split(' ')
H = int(s[0])
W = int(s[1])
a = [[0] * W for i in range(H)]
for i in range(H):
  t = input().rstrip().split(' ')
  for j in range(W):
    a[i][j] = int(t[j])
b = []
for k in range(W):
  c = int(input())
  b.append(c)
for l in range(H):
  sum = 0
  for m in range(W):
    x = int(a[l][m])
    y = int(b[m])
    sum += x * y
  print(sum)

Submission status: Accepted

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

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

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

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

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

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
n,m = LI()
A = [LI() for _ in range(n)]
B = [I() for _ in range(m)]
for i in range(n):
    temp = 0
    for j in range(m):
        temp += A[i][j]*B[j]
    print(temp)

Submission status: Accepted

Solution code:
#2020-03-19
n,m = map(int,input().split())
nm = [[0 for i in range(m)] for j in range(n)]

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

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

mg = [int(input()) for i in range(m)]
for x in range(n):
    for y in range(m):
        sum[x] += nm[x][y] * mg[y]
for x in range(n):
    print(sum[x])

Submission status: Accepted

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

A = []
B = []

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

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

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

Submission status: Accepted

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

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

for row in range(N):
    tmp = 0
    for col in range(M):
        tmp += A[row][col]* b[col]
    print(tmp)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,m = list(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):
    lst = list(map(int, input().split()))
    for j in range(m):
        # print(i, j)
        a[i][j] = lst[j]

for j in range(m):
    b[j] = 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 range(n)]
B = [int(input()) for _ in range(m)]
for a in A:
    tmp = 0
    for i, j in zip(a, B):
        tmp += i * j
    print(tmp)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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):
  a[i] = input().split()

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

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

Submission status: Accepted

Solution code:
aj = []
bj = []
c = []

n, m = list(map(int, input().split()))
for i in range(n):
    ai = list(map(int, input().split()))
    aj.append(ai)
for j in range(m):
    bj.append(input())
for k in range(n):
    ctmp = 0
    for l in range(m):
        ctmp = ctmp + int(aj[k][l])*int(bj[l])
    c.append(ctmp)
for o in range(n):
    print(c[o])

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = list()
b = list()
for i in range(n):
    a_i = list(map(int,input().split()))
    a.append(a_i)
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()
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):
    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 l in A:
  print(sum([val * b[num] for num, val in enumerate(l)]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = input().split()
n = int(n)
m = int(m)
A = [input() for i in range(n)]
B = [int(input()) for i in range(m)]
ans = 0
for i in A:
    y = 0
    b = i.split()
    for x in b:
        ans += int(x) * B[y]
        y += 1
    print(ans)
    ans = 0

Submission status: Accepted

Solution code:
i,j = map(int,input().split())
a = list()
b = list()
c = list()
c_e = 0

for r in range(i):
    e = list(map(int,input().split()))
    a.append(e)
    
for r in range(j):
    n = int(input())
    b.append(n)
    
for r in range(i):
    for t in range(j):
        c_e += a[r][t]*b[t]
    else:
        c.append(c_e)
        c_e = 0
        
for s in range(len(c)):
    print(c[s])

Submission status: Accepted

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

Submission status: Accepted

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

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

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

for k in range(n):
    r=0
    for l in range(m):
        r+=a[k][l]*b[l]
    print(r)

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()))) #(listが大事)
for i in range(m):
    b.append(int(input()))
#print(a)
#print(b)

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 = 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):
    c = 0
    for col in range(m):
        c += A[row][col] * B[col]
    print("%d" %(c))

Submission status: Accepted

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

matrix = [[0 for i in range(m)] for j in range(n)]
vector = [0 for i in range(m)]

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

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

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

Submission status: Accepted

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

#内積もとめる
for i in range(n):
    sum = 0
    for j in range(m):
        aij = a[i][j]
        bj = b[j][0]
        sum += aij * bj
    print(sum)

Submission status: Accepted

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

sum = [0]*n

for i in range(0,n):
    for j in range(0,m):
       sum[i] = sum[i] + l[i][j]*c[j]



for i in range(0,n):
    print(sum[i])

Submission status: Accepted

Solution code:
import sys
# import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

tower = [[[0] * 10 for i in range(3)] for j in range(4)]

N, M = map(int, readline().split())
A = [[int(i) for i in readline().split()] for _ in range(N)]
B = [int(readline()) for _ in range(M)]
li = [0] * N
for n,i in enumerate(A):
    for num, j in enumerate(B):
        li[n] += i[num] * j

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

Submission status: Accepted

Solution code:
def main(a, b):
    outputs = ''
    m = len(b)
    for row in a:
        result = 0
        for j in range(m):
            result += row[j]*b[j]
        outputs += '{}\n'.format(result)
    return outputs


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = [list(map(int, input().split())) for i in range(n)]
    b = [int(input()) for m in range(m)]
    print(main(a, b), end='')

Submission status: Accepted

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

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

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

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

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

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

for j in c:
    print(j)

Submission status: Accepted

Solution code:
n, m = map(lambda x: int(x), input().split(" "))
v = []
for i in range(n):
    v.append(list(map(lambda x: int(x), input().split(" "))))
q = []
for i in range(m):
    q.append(int(input()))
result = []
for i in range(n):
    x = 0
    for j, val in enumerate(v[i]):
        x += val * q[j]
    result.append(x)
for x in result:
    print(x)

Submission status: Accepted

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

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 j in range(m):
    b.append(int(input()))

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

Submission status: Accepted

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

#n= int(input())
#tmp= float(input())
tmp = input().split()
n,m = list(map(lambda a: int(a), tmp))

out=[]
for i in range(n):
    out.append(0)

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

#for i in range(n):
#    out=[]
#    out.append(0)

#print(out)
#print(a)
for i in range(m):
    b= int(input())
    for j in range(n):
        out[j]+=a[j][i]*b
#    print(out)

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

Submission status: Accepted

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

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

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

for ans_row in ans :
    print(ans_row)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a, b = map(int,input().split())

mat = []
vec = []
ans = []

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

for j in range(b):
    vec.append(int(input()))
        
for i in range(a):
    tmp = 0
    for j in range(b):
        tmp += mat[i][j] * vec[j]
    ans.append(tmp)

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
mn = input()
mn = mn.split()
m, n = int(mn[0]), int(mn[1])
A_array = list()
for i in range(m):
    A = input()
    A = A.split()
    A_array.append(A)
B_array = list()
for j in range(n):
    b = input()
    B_array.append(int(b))
for i in A_array:
    result = 0
    for A,B in zip(i,B_array):
        result += int(A)*int(B)
    else:
        print(result)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

a = list()
b = list()

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

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

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

Submission status: Accepted

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

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


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

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

Submission status: Accepted

Solution code:
x,y = map(int, input().split())

mat = [list(map(int, input().split())) for i in range(x)]
vct = [int(input()) for i in range(y)]

for m in mat:
    ddd = 0
    for a in range(y):
        ddd += m[a] * vct[a]
    print(ddd)

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

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

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

a = {}

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

b = {}

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

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

Submission status: Accepted

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

Submission status: Accepted

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

A = [ input().split() for l 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] += int(A[i][j]) * int(B[j])

#print(A[0][1])
#print(A)
#print(B)
#rint(C)

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

Submission status: Accepted

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

    print(answer)

Submission status: Accepted

Solution code:
matrixlst = []
vectorlst = []
vector2lst = []
tempresult = 0
count = 0
count2 = 0
i = 0
j = 0
finalA = 0
finalB = 0
testnumber = 0
n, m = input().split()
for b in range(int(n)):
    testinput = [int(x) for x in input().split()]
    for c in range(int(m)):
        matrixlst.append(testinput[count])
        count += 1
    count = 0
    testinput.clear()
for d in range(int(m)):
    testinput = int(input())
    vectorlst.append(testinput)
for e in range(int(n)):
    for f in range(int(m)):
        finalA = int(matrixlst[testnumber])
        finalB = int(vectorlst[j])
        tempresult += int(finalA * finalB)
        j += 1
        testnumber += 1
    vector2lst.append(tempresult)
    j = 0
    tempresult = 0
for g in range(int(n)):
    print(vector2lst[count2])
    count2 += 1

Submission status: Accepted

Solution code:
R,C = map(int,input().split(' '))
row_column = list()
for r in range(R):
    row_column.append(list(map(int,input().split(' '))))
for c in range(C):
    vector = int(input())
    for item in row_column:
        item[c] *= vector
for item in row_column:
    print(sum(item))

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