#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define RG register
#define file(x) freopen(#x".in", "r", stdin);freopen(#x".out", "w", stdout);
#define clear(x, y) memset(x, y, sizeof(x))
inline int read()
{
int data = 0, w = 1; char ch = getchar();
while(ch != '-' && (!isdigit(ch))) ch = getchar();
if(ch == '-') w = -1, ch = getchar();
while(isdigit(ch)) data = data * 10 + (ch ^ 48), ch = getchar();
return data * w;
}
const int maxn(3e6 + 10);
const double pi(acos(-1));
struct complex { double x, y; } a[maxn], b[maxn];
inline complex operator + (const complex &lhs, const complex &rhs)
{ return (complex) {lhs.x + rhs.x, lhs.y + rhs.y}; };
inline complex operator - (const complex &lhs, const complex &rhs)
{ return (complex) {lhs.x - rhs.x, lhs.y - rhs.y}; };
inline complex operator * (const complex &lhs, const complex &rhs)
{
return (complex) {lhs.x * rhs.x - lhs.y * rhs.y,
lhs.y * rhs.x + lhs.x * rhs.y};
}
int n, m, r[maxn], P;
template<int opt> void FFT(complex *p)
{
for(RG int i = 0; i < n; i++) if(i < r[i]) std::swap(p[i], p[r[i]]);
for(RG int i = 1; i < n; i <<= 1)
{
complex rot = (complex) {cos(pi / i), opt * sin(pi / i)};
for(RG int j = 0; j < n; j += (i << 1))
{
complex w = (complex) {1, 0};
for(RG int k = 0; k < i; ++k, w = w * rot)
{
complex x = p[j + k], y = w * p[i + j + k];
p[j + k] = x + y, p[i + j + k] = x - y;
}
}
}
}
int main()
{
#ifndef ONLINE_JUDGE
file(cpp);
#endif
n = read(), m = read();
for(RG int i = 0; i <= n; i++) a[i].x = read();
for(RG int i = 0; i <= m; i++) b[i].x = read();
for(m += n, n = 1; n <= m; n <<= 1, ++P);
for(RG int i = 0; i < n; i++)
r[i] = (r[i >> 1] >> 1) | ((i & 1) << (P - 1));
FFT<1>(a), FFT<1>(b);
for(RG int i = 0; i < n; i++) a[i] = a[i] * b[i];
FFT<-1>(a);
for(RG int i = 0; i <= m; i++) printf("%d ", (int)(a[i].x / n + .5));
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 10 us | 28 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 60.453 ms | 10 MB + 456 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #3 | 27.284 ms | 4 MB + 820 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #4 | 27.355 ms | 4 MB + 808 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 11.42 us | 28 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 10.34 us | 28 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 10.13 us | 28 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 55.138 ms | 10 MB + 188 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 55.133 ms | 10 MB + 188 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 49.844 ms | 9 MB + 944 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 60.788 ms | 10 MB + 536 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 60.562 ms | 9 MB + 416 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 8.99 us | 28 KB | Accepted | Score: 0 | 显示更多 |