Skip to content

Commit 85f1a9f

Browse files
Add files via upload
1 parent f7dc06f commit 85f1a9f

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Calculate the Dot Product of every row of A with B and check for which rows A[i].B + C > 0
2+
3+
-----
4+
5+
#include <iostream>
6+
#include <vector>
7+
#include <algorithm>
8+
9+
using namespace std;
10+
11+
int dot_product(vector <int> &A, vector <int> &B)
12+
{
13+
int answer = 0;
14+
for(int i = 1; i < A.size(); i++)
15+
{
16+
answer += A[i]*B[i];
17+
}
18+
return answer;
19+
}
20+
21+
int main()
22+
{
23+
int no_of_rows, no_of_columns, C;
24+
cin >> no_of_rows >> no_of_columns >> C;
25+
26+
vector <int> B(no_of_columns + 1);
27+
for(int i = 1; i <= no_of_columns; i++)
28+
{
29+
cin >> B[i];
30+
}
31+
32+
vector <vector <int> > A(no_of_rows + 1, vector <int> (no_of_columns + 1));
33+
for(int i = 1; i <= no_of_rows; i++)
34+
{
35+
for(int j = 1; j <= no_of_columns; j++)
36+
{
37+
cin >> A[i][j];
38+
}
39+
}
40+
41+
int good_rows = 0;
42+
for(int i = 1; i <= no_of_rows; i++)
43+
{
44+
good_rows += (dot_product(A[i], B) + C > 0);
45+
}
46+
47+
cout << good_rows << "\n";
48+
49+
return 0;
50+
}
51+
52+
53+

0 commit comments

Comments
 (0)