代码如下 #include <bits/stdc++.h> using namespace std; typedef long long LL; const LL mod = 998244353, g = 3, ig = 332748118; inline LL fpow(LL a, LL b) { LL ret = 1 % mod; for (; b; b >>= 1, a = a * a % mod) { if (b & 1) { ret = ret * a % mod; } } return ret; } void ntt(vector<LL> &v, vector<int> &rev, int opt) { int tot = v.size(); for (int i = 0; i < tot; i++) if (i < rev[i]) swap(v[i], v[rev[i]]); for (int mid = 1; mid < tot; mid <<= 1) { LL wn = fpow(opt == 1 ? g : ig, (mod - 1) / (mid << 1)); for (int j = 0; j < tot; j += mid << 1) { LL w = 1; for (int k = 0; k < mid; k++) { LL x = v[j + k],