「多项式对数函数」
前置知识
导数
微积分
基本问题
给定一个 (n) 次多项式 (F(x)),求 (G(x)) 满足:
[G(x)equiv ln^{F(x)}mod x^n ]
设
[Q(x)=ln^{(x)},Q'(x)=frac{1}{x}
]
则
[G(x)=Q(F(x))
]
两边同时求导
[G'(x)=Q'(F(x))F'(x)
]
[G'(x)=frac{F'(x)}{F(x)}
]
最后利用多项式求导来解决即可
代码
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 3e5 + 50, INF = 0x3f3f3f3f, mod = 998244353, inv3 = 332748118;
inline int read () {
register int x = 0, w = 1;
register char ch = getchar ();
for (; ch < '0' || ch > '9'; ch = getchar ()) if (ch == '-') w = -1;
for (; ch >= '0' && ch <= '9'; ch = getchar ()) x = x * 10 + ch - '0';
return x * w;
}
inline void write (register int x) {
if (x / 10) write (x / 10);
putchar (x % 10 + '0');
}
int n;
int f[maxn], g[maxn];
int rf[maxn], nf[maxn];
int res[maxn], rev[maxn];
inline int qpow (register int a, register int b, register int ans = 1) {
for (; b; b >>= 1, a = 1ll * a * a % mod)
if (b & 1) ans = 1ll * ans * a % mod;
return ans;
}
inline void NTT (register int len, register int * a, register int opt) {
for (register int i = 1; i < len; i ++) if (i < rev[i]) swap (a[i], a[rev[i]]);
for (register int d = 1; d < len; d <<= 1) {
register int w1 = qpow (opt, (mod - 1) / (d << 1));
for (register int i = 0; i < len; i += d << 1) {
register int w = 1;
for (register int j = 0; j < d; j ++, w = 1ll * w * w1 % mod) {
register int x = a[i + j], y = 1ll * w * a[i + j + d] % mod;
a[i + j] = (x + y) % mod, a[i + j + d] = (x - y + mod) % mod;
}
}
}
}
inline void Poly_Inv (register int d, register int * a, register int * b) { // 乘法逆
if (d == 1) return b[0] = qpow (a[0], mod - 2), void ();
Poly_Inv ((d + 1) >> 1, a, b);
register int len = 1, bit = 0;
while (len <= d << 1) len <<= 1, bit ++;
for (register int i = 0; i < len; i ++) res[i] = 0, rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << bit - 1);
for (register int i = 0; i < d; i ++) res[i] = a[i];
NTT (len, res, 3), NTT (len, b, 3);
for (register int i = 0; i < len; i ++) b[i] = ((2ll * b[i] % mod - 1ll * res[i] * b[i] % mod * b[i] % mod) % mod + mod) % mod;
NTT (len, b, inv3);
register int inv = qpow (len, mod - 2);
for (register int i = 0; i < d; i ++) b[i] = 1ll * b[i] * inv % mod; for (register int i = d; i < len; i ++) b[i] = 0;
}
inline void Poly_Ln (register int * f, register int * g) {
Poly_Inv (n + 1, f, nf);
for (register int i = 0; i <= n; i ++) rf[i] = 1ll * f[i + 1] * (i + 1) % mod;
register int len = 1, bit = 0;
while (len <= n << 1) len <<= 1, bit ++;
for (register int i = 0; i < len; i ++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << bit - 1);
NTT (len, rf, 3), NTT (len, nf, 3);
for (register int i = 0; i < len; i ++) g[i] = 1ll * rf[i] * nf[i] % mod;
NTT (len, g, inv3);
register int inv = qpow (len, mod - 2);
for (register int i = 0; i <= n; i ++) g[i] = 1ll * g[i] * inv % mod; for (register int i = n + 1; i < len; i ++) g[i] = 0;
for (register int i = n; i >= 1; i --) g[i] = 1ll * g[i - 1] * qpow (i, mod - 2) % mod; g[0] = 0;
}
int main () {
n = read() - 1;
for (register int i = 0; i <= n; i ++) f[i] = read(); Poly_Ln (f, g);
for (register int i = 0; i <= n; i ++) printf ("%d ", g[i]); putchar ('
');
return 0;
}