RXD and functions

题目链接

题意

已知
定义变换$Tr(f,a)$,使得
已知,且有,输入
取模。

思路

推式子时间到。

其中

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[33;1m" << #x << "->" ; err(x);} while (0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x){for (auto v: a) cout << v << ' '; err(x...);}
template<typename T, typename... A>
void err(T a, A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
#define inf 1ll << 50

const ll mod = 998244353;
const ll g = 3;
ll Pow(ll a, ll b)
{
ll ans = 1;
while (b)
{
if (b & 1)
ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans;
}

void change(ll y[],int len)
{
for(int i = 1, j = len / 2; i < len - 1; i++)
{
if (i < j)
swap(y[i], y[j]);
int k = len / 2;
while (j >= k)
{
j -= k;
k /= 2;
}
if (j < k)
j += k;
}
}
void ntt(ll y[], int len, int on)
{
change(y, len);
for(int h = 2; h <= len; h <<= 1)
{
ll wn = Pow(g, (mod-1) / h);
if(on == -1)
wn = Pow(wn, mod-2);
for(int j = 0; j < len; j += h)
{
ll w = 1LL;
for (int k = j; k < j + h / 2; k++)
{
ll u = y[k];
ll t = w * y[k + h / 2] % mod;
y[k] = (u + t) % mod;
y[k + h / 2] = (u - t + mod) % mod;
w = w * wn % mod;
}
}
}
if (on == -1)
{
ll t = Pow(len, mod-2);
for(int i = 0; i < len; i++)
y[i] = y[i] * t % mod;
}
}
const int N = 1e5 + 5;
ll c[N], b[N];
ll x1[N << 2], x2[N << 2];
ll fac[N], inv[N];
int main()
{
ll n, m;
fac[0] = 1;
for (int i = 1; i <= 100000; i++)
fac[i] = fac[i - 1] * i % mod;
inv[100000] = Pow(fac[100000], mod - 2);
for (int i = 99999; i >= 0; i--)
inv[i] = inv[i + 1] * (i + 1) % mod;
while (scanf("%lld", &n) != EOF)
{
for (int i = 0; i <= n; i++)
scanf("%lld", &c[i]);
ll s = 0;
scanf("%lld", &m);
for (int i = 1; i <= m; i++)
{
ll a;
scanf("%lld", &a);
s = (s + a + mod) % mod;
}
if (s == 0)
{
for (int i = 0; i <= n; i++)
printf("%lld ", c[i]);
putchar('\n');
continue;
}
int len = 1;
while (len <= 2 * (n + 1))
len <<= 1;
for (int i = 0; i <= len; i++)
x1[i] = x2[i] = 0;
for (int i = 0; i <= n; i++)
x1[i] = c[i] * fac[i] % mod;
ll tmp = 1ll;
for (int i = n; i >=0; i--)
{
x2[i] = tmp * inv[n - i] % mod;
tmp = tmp * (-s) % mod;
tmp = (tmp + mod) % mod;
}
ntt(x1, len, 1);
ntt(x2, len, 1);
for (int i = 0; i < len; i++)
x1[i] = x1[i] * x2[i] % mod;
ntt(x1, len, -1);
for (int i = n; i <= 2 * n; i++)
printf("%lld ", x1[i] * inv[i - n] % mod);
putchar('\n');
}
return 0;
}
0%