/
convolution_mod.test.cpp
43 lines (32 loc) · 1.04 KB
/
convolution_mod.test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#define PROBLEM "https://judge.yosupo.jp/problem/convolution_mod"
#include <iostream>
#include <atcoder/modint>
#include <atcoder/convolution>
using mint = atcoder::modint998244353;
std::istream& operator>>(std::istream& in, mint& a) {
long long e; in >> e; a = e;
return in;
}
std::ostream& operator<<(std::ostream& out, const mint& a) {
out << a.val();
return out;
}
#include "library/convolution/semi_relaxed_convolution.hpp"
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::size_t n, m;
std::cin >> n >> m;
std::vector<mint> a(n), b(m);
for (auto& e : a) std::cin >> e;
for (auto& e : b) std::cin >> e;
suisen::SemiRelaxedConvolution<mint> conv{ a, [](const auto& a, const auto& b) { return atcoder::convolution(a, b); } };
for (std::size_t i = 0; i < n + m - 1; ++i) {
conv.append(i < b.size() ? b[i] : 0);
}
auto c = conv.get();
for (std::size_t i = 0; i < n + m - 1; ++i) {
std::cout << c[i] << " \n"[i == n + m - 2];
}
return 0;
}