Skip to content

Instantly share code, notes, and snippets.

@oskimura
Created December 15, 2017 05:20
Show Gist options
  • Save oskimura/3392ec2fc56cc356834afa0d56417719 to your computer and use it in GitHub Desktop.
Save oskimura/3392ec2fc56cc356834afa0d56417719 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
int main()
{
int n,m;
std::cin >> n >> m;
int **matrix = new int*[n];
for (int i=0;i<n;i++) {
matrix[i] = new int[m];
}
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
int num;
std::cin >> num;
matrix[i][j] = num;
}
}
int *vec = new int[m];
for (int i=0;i<m;i++) {
std::cin >> vec[i];
}
int *result = new int[n];
for (int i=0;i<n;i++) {
int c = 0;
for (int j=0;j<m;j++) {
c = c + vec[j] * matrix[i][j];
}
result[i] = c;
}
for (int i=0; i<n;i++) {
std::cout << result[i] << std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment