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

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

   
for i in A:
    answer_sum = 0 
    for j,k in enumerate(B):
        a = i[j]*k
        answer_sum  += a
    print(answer_sum)

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

for _ in range(n):
    a = [int(x) for x in input().split()]
    for i,j in enumerate(a):
        A[_][i] = j

for _ in range(0, m):
    B[_] = int(input())

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

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

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

Submission status: Accepted

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

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

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


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

Submission status: Accepted

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

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

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

#print(A)
#print(B)

result=[]
for i in range(n):
    sum = 0
    for j in range(m):
        #print(i,j,":",A[i][j],B[j])
        sum += A[i][j]*B[j]
    result.append(sum)

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

Submission status: Accepted

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

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

def seki(x, y):
    return x*y

for i in range(n):
    print(sum(list(map(seki, a[i], b))))

Submission status: Accepted

Solution code:
#coding: utf-8

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

Submission status: Accepted

Solution code:
def test():

	inputs = list(map(int,input().split()))

	n = inputs[0]
	m = inputs[1]

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

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

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

		print(f"{Answer[i]}")


if __name__ == "__main__":
	test()

Submission status: Accepted

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

Submission status: Accepted

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

a = [[0 for i in range(c)] for i in range(r)]

for i in range(r):
    k = 0
    for j in map(int, input().split()):
        a[i][k] = j
        k+=1

b = [0] * c

for i in range(c):
    b[i] = int(input())
    
for i in range(r):
    t = 0
    for j in range(c):
        t+=(a[i][j] * b[j])
    print(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)]
[print(sum([j*k for j,k in zip(a[i],b)]))for i in range(n)]

Submission status: Accepted

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

for Ai in A:
    ans = 0
    for a, b in zip(Ai, B):
        ans += a * b
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
f=lambda:list(map(int,input().split()))
n,m=f()
M=[f()for _ in [0]*n]
V=[f()[0]for _ in [0]*m]
for v in M:print(sum(i*j for i,j in zip(v,V)))

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 = [int(input()) for i in range(m)]

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:
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 10 03:11:43 2019

@author: Atsushi
"""

a,b = map(int,input().split())
mat = []

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

Submission status: Accepted

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

'''
考えたプログラム

二次元配列を組む
list_m =[[0 for p in range(m)] for q in range(n)]

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

1次元配列を組む
list_v = [0 for r in range(m)]

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

sum0 = 0
for p in range(n):
    for q in range(m):
        sum0 += list_m[p][q] * list_v[q]
    print(sum0)
    sum0 = 0
'''

Submission status: Accepted

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

# 行列の読み込み
for i in range(n):
    mat[i] = list(map(int, input().split()))

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

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

Submission status: Accepted

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

A=[list(map(int,input().split())) for y in range(n)]
B=[int(input()) for y 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)]
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):
    tmp = 0
    for col in range(M):
        tmp += A[row][col]*B[col]
    print("%d"%(tmp))

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:
import sys,os,re
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate
sys.setrecursionlimit(10**6)

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

c = [0] * n

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

for c_ in c:
    print(c_)

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    tmpc = 0
    for j in range(m):
        tmpc+=l[i][j]*l2[j]
    print(tmpc)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
list_arr = []
list_vec = []
list_ans = []
gyou, retsu = list(map(int, input().split()))
for count in range(gyou):
    arr = list(map(int, input().split()))
    list_arr.append(arr)
for count in range(retsu):
    vec = int(input())
    list_vec.append(vec)
for count1 in range(gyou):
    for count2 in range(retsu):
        list_ans.append(list_arr[count1][count2] * list_vec[count2])
    print(sum(list_ans))
    list_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(len(a)):
    ans = 0
    for j in range(len(b)):
        ans += a[i][j] * b[j]
    print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
A=[[0 for aa in range(m)]for bb in range(n)]
b=[0 for cc in range(m)]
for zz in range(n):
	unko=list(map(int,input().split()))
	for yy in range(m):
		A[zz][yy]=unko[yy]
for dd in range(m):
	b[dd]=int(input())
for aaa in range (n):
	ole=0
	for bbb in range(m):
		ole=ole+(A[aaa][bbb]*b[bbb])
	print(ole)

Submission status: Accepted

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

l = []
for x in range(m) :
  m2 = int(input())
  l.append(m2)

  
for i in range(n):
  R = [x*y for (x,y) in zip(l,T[i])]
  R1 = sum(R)
  print(R1)

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 = [[0 for j in range(m)]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 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())

A = []
B = []
C = []

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

for _ 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]

    C.append(c)

for c in C:
    print(c)

Submission status: Accepted

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

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

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):
    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 = []
b = []
c = 0

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):
    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 = []
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:
if __name__ == "__main__":
    n, m = map(lambda x: int(x), input().split())

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

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

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

    for row in range(n):
        sum = 0
        for col in range(m):
            sum += A[row][col] * B[col]
        print(f"{sum}")

Submission status: Accepted

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

matrix = [[0 for  _ in range(m)] for _ in range(n)]

for i in range(n):
    List = list(map(int, input().split()))
    for j in range(m):
        matrix[i][j] = Ⅼist[j]
    

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

Answer = []

for item in matrix:
    figure = 0
    for i in range(m):
        figure += item[i]*multiple[i]
    Answer.append(figure)

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

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

Submission status: Accepted

Solution code:
# n*mの行列Aとm*1のベクトルbの積を出力するプログラム
n, m = input().split()
n = int(n)
m = int(m)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sizes = list(map(int, input().split()))
matrix = []
for i in range(sizes[0]):
    matrix.append(list(map(int, input().split())))
vec = []
for i in range(sizes[1]):
    vec.append(int(input()))
for i in range(sizes[0]):
    val = 0
    for j in range(sizes[1]):
        val += vec[j]*matrix[i][j]
    print (val)

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 ai in a:
		print(sum([x[0] * x[1] for x in zip(ai, b)]))

main()

Submission status: Accepted

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

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

array_2 = [[] for i in range(n)]
for i in range(n):
    array_2[i] = int(input())

for row in range(m):
    sum = 0
    for cols in range(n):
        sum += array_1[row][cols]*array_2[cols]
    print(sum)

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

Ab = []
for i in range(n):
  Ab.append(0)
  for k in range(m):
    Ab[i] += A[i][k] * b[k]

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 _ in range(n)]
b=[list(map(int,input().split())) 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][0]
    print(c[i])

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)]
s = map(str, [sum([x * y for x, y in zip(aa, b)]) for aa in a])
print('\n'.join(s))

Submission status: Accepted

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


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


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




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

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
A = [[]*m for i in range(n)]
for i in range(n):
    A[i] = list(map(int,input().split()))
b = [[]*1 for i in range(m)]
for i in range(m):
    b[i] = int(input())
for i in range(n):
    tmp = 0
    for j in range(m):
        tmp += A[i][j] * b[j]
    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 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 = []
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):
  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 = 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 = [[] for _ in range(n)]
 
for i in range(n):
  a[i] = list(map(int, input().split()))
 
b = [0 for _ 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:
L=input().split( )
n=int(L[0])
m=int(L[1])
 
A=[[0 for i in range(m)] for j in range(n)]
b=[0 for i in range(m)]
x=0
y=0
while x<n:
    StrCollum = input().split( )
    for k in range(m):
        A[x][k] = int(StrCollum[k])
    x+=1
while y<m:
    StrVec = input()
    b[y] = int(StrVec)
    y+=1
c=[0 for i in range(n)]
for z in range(n):
    sum=0
    for u in range(m):
        sum = sum+(A[z][u]*b[u])
        c[z]=sum
for j in range(n):
    print(c[j])

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

# print(a)
# print(b)

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

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

Submission status: Accepted

Solution code:
A = []
b = []
c = []

line, row = list(map(int, input().split()))

for _ in range(line):
    A.append(list(map(int, input().split())))

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

for l in range(line):
    tmp = 0
    for r in range(row):
        tmp += A[l][r] * b[r]
    c.append(tmp)

for e in c:
    print(e)

Submission status: Accepted

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

A=[[0 for i in range(m)] for j in range(n)]
b=[0 for i in range(m)]
x=0
y=0
while x<n:
    StrCollum = input().split( )
    for k in range(m):
        A[x][k] = int(StrCollum[k])
    x+=1
while y<m:
    StrVec = input()
    b[y] = int(StrVec)
    y+=1
c=[0 for i in range(n)]
for z in range(n):
    sum=0
    for u in range(m):
        sum = sum+(A[z][u]*b[u])
        c[z]=sum
for j in range(n):
    print(c[j])

Submission status: Accepted

Solution code:
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def main():
    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 i in range(M):
        b.append(int(input()))
    
    ans = mymath.mul(A,b)

    for i in ans:
        print(i)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)


def main():
    a,b=map(int,input().split())
    g=[list(map(int,input().split()))for i in range(a)]
    h=[int(input())for i in range(b)]
    for i in g:
        print(sum(s*t for s,t in zip(i,h)))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

matrix_A = []
vector_b = []
vector_c = [0 for i in range(n)]

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

for _ in range(m):
    vector_b.extend([int(input())])

# CALC, OUTPUT
for cnt_n in range(n):
    for cnt_m in range(m):
        vector_c[cnt_n] += matrix_A[cnt_n][cnt_m] * vector_b[cnt_m]
        
    print(vector_c[cnt_n])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
size = input().split()
a_list = [[0 for m in range(int(size[1]))] for n in range(int(size[0]))]
b_list = [[0] for m in range(int(size[1]))]

for n in range(int(size[0])):
    data = input().split()
    for m in range(int(size[1])):
        a_list[n][m] = int(data[m])

for i in range(int(size[1])):
    b_list[i][0] = int(input())

for n in range(int(size[0])):
    c = 0
    for m in range(int(size[1])):
        c += a_list[n][m] * b_list[m][0]
    print(c)

Submission status: Accepted

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

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()
for i in range(n) :   #1行ずつn行まで読み込みlistに格納
 a.append(list(map(int, input().split())))
b = list()
for j 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 = list()
for i in range(n) :   #1行ずつn行まで読み込みlistに格納
 a.append(list(map(int, input().split())))
b = list()
for j 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 = list()
for i in range(n) :   
 a.append(list(map(int, input().split())))
b = list()
for j 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 = list()
for i in range(n) :   #1行ずつn行まで読み込みlistに格納
 a.append(list(map(int, input().split())))
b = list()
for j 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:
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
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):
    tmp = 0
    for col in range(M):
        tmp += A[row][col]*B[col]
    print("%d"%(tmp))