不要被标题蒙骗啦 \sim

其实这就是个模拟,高精度乘法,复杂度 O(nm)O(nm) 就可以接受啦 \sim

考虑我们平时怎么做乘法的,实际上就是把两个大数 aabb 的每一位去乘另外一个数,然后对应相加就可以,这里我们用一个数组 cc 来存储这个信息:

ci+jci+j+ai×bjc_{i+j}\leftarrow c_{i+j}+a_i\times b_j

即可。

#include<cstdio>
int init(){
	char c = getchar();
	int x = 0, f = 1;
	for (; c < '0' || c > '9'; c = getchar())
		if (c == '-') f = -1;
	for (; c >= '0' && c <= '9'; c = getchar())
		x = (x << 1) + (x << 3) + (c ^ 48);
	return x * f;
}
void print(int x){
	if (x < 0) x = -x, putchar('-');
	if (x > 9) print(x / 10);
	putchar(x % 10 + '0');
}
const int N = (int) 1e3 + 5;
int a[N], b[N], c[N];
int main(){
    int n = init(), m = init();
    for (int i = 0; i <= n; ++i)
        a[i] = init();
    for (int j = 0; j <= m; ++j)
        b[j] = init();
    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= m; ++j)
            c[i + j] += a[i] * b[j];
    for (int i = 0; i <= n + m; ++i)
        print(c[i]), putchar(' ');
}