https://www.luogu.org/problemnew/solution/P4002 神树的题解写的很清楚了。稍微补充:
1.[x^i]ln(A(ax))=a^i[x^i]ln(A(x)),感觉直接证并非那么显然,大约是先求出多项式再把ax作为自变量带回去。
2.最后一句中的式子,即考虑由ai组成的|S|=k的S集合在xk中被统计了几次,容易发现仅当这个Σ∏(1-ajx) (i=1~n,j≠i)中的ai不在S中出现会被统计一次,于是统计次数为n-k,所以乘上n-k即为所要的系数。
#include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; #define ll long long #define N 150010 #define P 998244353 char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;} int gcd(int n,int m){return m==0?n:gcd(m,n%m);} int read() { int x=0,f=1;char c=getchar(); while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();} while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar(); return x*f; } int n,m,s[N],a[N],b[N],c[N],d[N],e[N],f[N],g[N],h[N],A[N],B[N],r[N],fac[N],t; int ksm(int a,int k) { int s=1; for (;k;k>>=1,a=1ll*a*a%P) if (k&1) s=1ll*s*a%P; return s; } int inv(int a){return ksm(a,P-2);} void DFT(int *a,int n,int g) { for (int i=0;i<n;i++) r[i]=(r[i>>1]>>1)|(i&1)*(n>>1); for (int i=0;i<n;i++) if (i<r[i]) swap(a[i],a[r[i]]); for (int i=2;i<=n;i<<=1) { int wn=ksm(g,(P-1)/i); for (int j=0;j<n;j+=i) { int w=1; for (int k=j;k<j+(i>>1);k++,w=1ll*w*wn%P) { int x=a[k],y=1ll*w*a[k+(i>>1)]%P; a[k]=(x+y)%P,a[k+(i>>1)]=(x+P-y)%P; } } } } void IDFT(int *a,int n) { DFT(a,n,inv(3)); int u=inv(n); for (int i=0;i<n;i++) a[i]=1ll*a[i]*u%P; } void mul(int *a,int *b,int n) { DFT(a,n,3),DFT(b,n,3); for (int i=0;i<n;i++) a[i]=1ll*a[i]*b[i]%P; IDFT(a,n);IDFT(b,n); } void Inv(int *a,int *b,int n) { if (n==1){for (int i=0;i<t;i++) b[i]=0;b[0]=inv(a[0]);return;} Inv(a,b,n>>1); for (int i=0;i<n;i++) A[i]=a[i]; for (int i=n;i<(n<<1);i++) A[i]=0; n<<=1; DFT(b,n,3),DFT(A,n,3); for (int i=0;i<n;i++) b[i]=1ll*b[i]*(P+2-1ll*A[i]*b[i]%P)%P; IDFT(b,n); n>>=1; for (int i=n;i<(n<<1);i++) b[i]=0; } void trans(int *a,int *b,int n){for (int i=n-1;i>=0;i--) b[i]=1ll*a[i+1]*(i+1)%P;} void dx(int *a,int *b,int n){b[0]=0;for (int i=1;i<n;i++) b[i]=1ll*a[i-1]*inv(i)%P;} void Ln(int *a,int n) { for (int i=0;i<n;i++) b[i]=c[i]=0; Inv(a,b,n>>1); trans(a,c,n>>1); mul(b,c,n); dx(b,a,n); } void Exp(int *a,int *b,int n) { if (n==1){b[0]=1;return;} Exp(a,b,n>>1); for (int i=0;i<(n>>1);i++) B[i]=b[i]; for (int i=(n>>1);i<n;i++) B[i]=0; Ln(B,n); for (int i=0;i<n;i++) B[i]=(a[i]-B[i]+P)%P; B[0]=(B[0]+1)%P; n<<=1; for (int i=(n>>1);i<n;i++) B[i]=0; mul(b,B,n); n>>=1; for (int i=n;i<(n<<1);i++) b[i]=0; } void solve(int l,int r,int *a) { if (l==r) {a[0]=1;a[1]=P-s[l];return;} int mid=l+r>>1; int t=1;while (t<=r-l+1) t<<=1; int A[t],B[t];memset(A,0,sizeof(A)),memset(B,0,sizeof(B)); solve(l,mid,A),solve(mid+1,r,B); mul(A,B,t); for (int i=0;i<t;i++) a[i]=A[i]; } int main() { #ifndef ONLINE_JUDGE freopen("bzoj5119.in","r",stdin); freopen("bzoj5119.out","w",stdout); const char LL[]="%I64d "; #else const char LL[]="%lld "; #endif n=read(),m=read(); for (int i=1;i<=n;i++) s[i]=read(); fac[0]=1;for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%P; int t=1;while (t<=(n<<1)) t<<=1; for (int i=0;i<n;i++) f[i]=1ll*ksm(i+1,m)*inv(fac[i])%P; for (int i=0;i<n;i++) g[i]=1ll*ksm(i+1,m)*f[i]%P; Inv(f,a,t>>1); mul(g,a,t); for (int i=n;i<t;i++) g[i]=0; Ln(f,t); solve(1,n,h); Inv(h,e,t>>1); for (int i=0;i<n;i++) h[i]=1ll*h[i]*(n-i)%P; mul(h,e,t); for (int i=0;i<n;i++) g[i]=1ll*g[i]*h[i]%P; for (int i=0;i<n;i++) f[i]=1ll*f[i]*h[i]%P; Exp(f,d,t); for (int i=(t>>1);i<t;i++) d[i]=0; mul(d,g,t); int ans=d[n-2]; for (int i=1;i<=n;i++) ans=1ll*ans*s[i]%P; cout<<1ll*ans*fac[n-2]%P; return 0; }