题目链接
https://www.nowcoder.com/acm/contest/85/D
思路
因为数据范围较小 ,所以 可以直接 一个一个乘
AC代码
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 1e3 + 5;
const int MOD = 1e9 + 7;
int ans[maxn];
struct Node
{
int x, y;
}q[maxn];
int main()
{
memset(q, 0, sizeof(q));
memset(ans, 0, sizeof(ans));
int n, m, num, count = 0;
scanf("%d%d", &n, &m);
for (int i = 0; i <= n; i++)
{
scanf("%d", &num);
if (num)
{
q[count].x = num;
q[count].y = i;
count++;
}
}
for (int i = 0; i <= m; i++)
{
scanf("%d", &num);
if (num)
{
for (int j = 0; j < count; j++)
ans[i + q[j].y] += num * q[j].x;
}
}
int len = n + m + 1;
for (int i = 0; i < len; i++)
{
if (i)
printf(" ");
printf("%d", ans[i]);
}
printf("\n");
}