题意:求$\sum_{i=0}^{n}\sum_{j=0}^{i}S(i,j)2^{j}j!$
A look that can not be done ...
But still requires careful analysis of
The most important step is the conversion:
The number of classes is defined a second Stirling: $ S (n, m) $ represents the program sets $ $ $ different articles to the n-m of $
Then consider things inside that summation, the meaning is found different $ $ I $ J $ articles to the sets, each set has two kinds of attributes, then the whole set of these programs are arranged Number
So based on this definition, the reset state $ g (n) = \ sum_ {j = 0} ^ {i} S (i, j) 2 ^ {j} j $, then there recursive formula:! $ G (n) = \ sum_ {j = 1} ^ {n} 2C_ {n} ^ {i} g (ni) $
This recursive enumeration is the origin of the first set of elements obtained
Routine according to expand the number of combinations, to give:
$g(n)=\sum_{i=1}^{n}2\frac{n!}{i!(n-i)!}g(n-i)$
Transposition can be obtained:
$\frac{g(n)}{n!}=\sum_{i=1}^{n}\frac{2}{i!}\frac{g(n-i)}{(n-i)!}$
So the right is clearly a form of convolution
设$F(x)=\sum_{i=1}^{n}\frac{2}{i!}x^{i}$
$G(x)=\sum_{i=0}^{n}\frac{g(i)}{(i)!}x^{i}$
Noting this case the direct convolution $ G (0) = 0 $, but it requires $ G (0) = 1 $ (boundary requirement)
Thus it can be determined $ G (x) = F (x) G (x) + 1 $
Transposition obtain $ G (x) = \ frac {1} {1-F (x)} $
(This method can be used like moisture cure, said FFT)
Etc., to obtain a $ G (x) $ What is the use?
See, for $ G (x) $ I $ by each! $ Obtain $ g (x) $ generating function, can be directly summed
Paste the code:
#include <cstdio> #include <cmath> #include <cstring> #include <cstdlib> #include <iostream> #include <algorithm> #include <queue> #include <stack> #define ll long long using namespace std; const ll mode=998244353; ll F[100005]; ll FF[100005]; ll G[100005]; ll inv[100005]; ll mul[100005]; ll minv[100005]; int to[(1<<20)+5]; int n; void init() { inv[0]=inv[1]=mul[0]=mul[1]=minv[0]=minv[1]=1; for(int i=2;i<=100000;i++) { inv[i]=(mode-mode/i)*inv[mode%i]%mode; minv[i]=minv[i-1]*inv[i]%mode; mul[i]=mul[i-1]*i%mode; } } ll pow_mul(ll x,ll y) { ll ret=1; while(y) { if (y & 1 ) the right = K * x% fashion; x=x*x%mode,y>>=1; } Return the right; } void NTT(ll *a,int len,int k) { for(int i=0;i<len;i++)if(i<to[i])swap(a[i],a[to[i]]); for(int i=1;i<len;i<<=1) { ll w0=pow_mul(3,(mode-1)/(i<<1)); for(int j=0;j<len;j+=(i<<1)) { ll w=1; for(int o=0;o<i;o++,w=w*w0%mode) { ll w1=a[j+o],w2=a[j+o+i]*w; a[j+o]=(w1+w2)%mode,a[j+o+i]=((w1-w2)%mode+mode)%mode; } } } if(k==-1) { ll inv=pow_mul(len,mode-2); for(int i=1;i<(len>>1);i++)swap(a[i],a[len-i]); for(int i=0;i<len;i++)a[i]=a[i]*inv%mode; } } ll A[(1<<20)+5],B[(1<<20)+5],C[(1<<20)+5]; void get_inv(ll *f,ll *g,int dep) { if(dep==1) { g[0]=pow_mul(f[0],mode-2); return; } int nxt=(dep+1)>>1; get_inv(f,g,nxt); int lim=1,l=0; while(lim<=2*dep)lim<<=1,l++; for(int i=0;i<lim;i++)to[i]=((to[i>>1]>>1)|((i&1)<<(l-1))); for(int i=0;i<lim;i++)A[i]=B[i]=0; for(int i=0;i<dep;i++)A[i]=f[i]; for(int i=0;i<nxt;i++)B[i]=g[i]; NTT(A,lim,1),NTT(B,lim,1); for(int i=0;i<lim;i++)C[i]=A[i]*B[i]%mode*B[i]%mode; NTT(C,lim,-1); for(int i=0;i<dep;i++)g[i]=((2*g[i]-C[i])%mode+mode)%mode; } int main () { scanf("%d",&n); init(); n++; for(int i=1;i<n;i++)F[i]=(-2ll*minv[i]%mode+mode)%mode; F[0]=1; get_inv(F,FF,n); ll s=0; for(int i=0;i<n;i++)s=(s+FF[i]*mul[i]%mode)%mode; printf("%lld\n",s); return 0; }