\(\text{Problem}:\)第二类斯特林数·行
\(\text{Solution}:\)
引理 \(1\):
\[x^{n}=\sum\limits_{i=0}^{n}\binom{x}{i}{n\brace i}i! \]把上界 \(n\) 改为 \(x\) 就可以二项式反演了。设 \(f(x)=x^{n},g(x)={n\brace x}x!\),有:
\[\begin{aligned} f(x)&=\sum\limits_{i=0}^{x}\binom{x}{i}g(i)\\ g(x)&=\sum\limits_{i=0}^{x}(-1)^{x-i}\binom{x}{i}f(i) \end{aligned} \]令 \(A_{i}=\dfrac{(-1)^{i}}{i!},B_{i}=\dfrac{f(i)}{i!},C_{i}=\dfrac{g(i)}{i!}\),得到:
\[C_{i}=\sum\limits_{j=0}^{i}A_{j}B_{i-j} \]利用多项式卷积即可在 \(O(n\log n)\) 的时间复杂度内求出 \(C\) 的每一项,即可以求出一行的第二类斯特林数。
\(\text{Code}:\)
#include <bits/stdc++.h>
#pragma GCC optimize(3)
//#define int long long
#define ri register
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define is insert
#define es erase
#define vi vector<int>
#define vpi vector<pair<int,int>>
using namespace std; const int N=550010, Mod=167772161;
inline int read()
{
int s=0, w=1; ri char ch=getchar();
while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
return s*w;
}
int n,A[N],B[N],C[N],fac[N];
int rev[N],T=1,r[26][2];
inline int ksc(int x,int p) { int res=1; for(;p;p>>=1, x=1ll*x*x%Mod) if(p&1) res=1ll*res*x%Mod; return res; }
inline void Get_Rev() { for(ri int i=0;i<T;i++) rev[i]=(rev[i>>1]>>1)|((i&1)?(T>>1):0); }
inline void NTT(int *s,int type)
{
for(ri int i=0;i<T;i++) if(rev[i]<i) swap(s[i],s[rev[i]]);
for(ri int i=2,cnt=1;i<=T;i<<=1,cnt++)
{
int wn=r[cnt][type];
for(ri int j=0,mid=(i>>1);j<T;j+=i)
{
for(ri int k=0,w=1;k<mid;k++,w=1ll*w*wn%Mod)
{
int x=s[j+k], y=1ll*w*s[j+mid+k]%Mod;
s[j+k]=(x+y)%Mod;
s[j+mid+k]=x-y;
if(s[j+mid+k]<0) s[j+mid+k]+=Mod;
}
}
}
if(!type) for(ri int i=0,inv=ksc(T,Mod-2);i<T;i++) s[i]=1ll*s[i]*inv%Mod;
}
signed main()
{
r[25][1]=ksc(3,5), r[25][0]=ksc(ksc(3,Mod-2),5);
for(ri int i=24;~i;i--) r[i][0]=1ll*r[i+1][0]*r[i+1][0]%Mod, r[i][1]=1ll*r[i+1][1]*r[i+1][1]%Mod;
n=read();
while(T<=n+n) T<<=1;
Get_Rev();
fac[0]=1;
for(ri int i=1;i<N;i++) fac[i]=1ll*fac[i-1]*i%Mod;
for(ri int i=0;i<=n;i++)
{
A[i]=((i&1)?(-1):(1))*ksc(fac[i],Mod-2);
if(A[i]<0) A[i]+=Mod;
B[i]=1ll*ksc(i,n)*ksc(fac[i],Mod-2)%Mod;
}
NTT(A,1), NTT(B,1);
for(ri int i=0;i<T;i++) C[i]=1ll*A[i]*B[i]%Mod;
NTT(C,0);
for(ri int i=0;i<=n;i++) printf("%d ",C[i]);
puts("");
return 0;
}