S(i,j)=Σ(-1)(1/j!)·C(j,k)·k=Σ(-1)·k/k!/(j-k)!。原式=ΣΣ(-1)·k·2·j!/k!/(j-k)! (i,j=0~n)。可以发现i只在式中出现了一次且与j不相关,如果对每个k求出其剩余部分的答案,各自乘一下即可。而剩余部分显然是一个卷积。
#include<bits/stdc++.h>
using namespace std;
int getbit(){char c=getchar();while (c<''||c>'') c=getchar();return c^;}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 100010
#define P 998244353
#define inv3 332748118
int n,r[N<<],fac[N],inv[N],f[N<<],g[N<<];
int ksm(int a,int k)
{
int s=;
for (;k;k>>=,a=1ll*a*a%P) if (k&) s=1ll*s*a%P;
return s;
}
int C(int n,int m){if (m>n) return ;return 1ll*fac[n]*inv[m]%P*inv[n-m]%P;}
void DFT(int *a,int n,int g)
{
for (int i=;i<n;i++) if (i<r[i]) swap(a[i],a[r[i]]);
for (int i=;i<=n;i<<=)
{
int wn=ksm(g,(P-)/i);
for (int j=;j<n;j+=i)
{
int w=;
for (int k=j;k<j+(i>>);k++,w=1ll*w*wn%P)
{
int x=a[k],y=1ll*w*a[k+(i>>)]%P;
a[k]=(x+y)%P,a[k+(i>>)]=(x-y+P)%P;
}
}
}
}
void mul(int *f,int *g)
{
int t=;while (t<=(n<<)) t<<=;
for (int i=;i<t;i++) r[i]=(r[i>>]>>)|(i&)*(t>>);
DFT(f,t,),DFT(g,t,);
for (int i=;i<t;i++) f[i]=1ll*f[i]*g[i]%P;
DFT(f,t,inv3);
int u=ksm(t,P-);
for (int i=;i<t;i++) f[i]=1ll*f[i]*u%P;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("b.in","r",stdin);
freopen("b.out","w",stdout);
const char LL[]="%I64d\n";
#else
const char LL[]="%lld\n";
#endif
n=read();
fac[]=;for (int i=;i<=n;i++) fac[i]=1ll*fac[i-]*i%P;
inv[]=inv[]=;for (int i=;i<=n;i++) inv[i]=P-1ll*(P/i)*inv[P%i]%P;
for (int i=;i<=n;i++) inv[i]=1ll*inv[i]*inv[i-]%P;
for (int i=;i<=n;i++) g[i]=1ll*ksm(,i)*fac[i]%P;reverse(g,g+n+);
for (int i=;i<=n;i++) if (i&) f[i]=P-inv[i];else f[i]=inv[i];
mul(f,g);
reverse(f,f+n+);
for (int i=;i<=n;i++) f[i]=1ll*f[i]*inv[i]%P;
f[]=1ll*f[]*(n+)%P;
for (int k=;k<=n;k++)
f[k]=1ll*f[k]*(ksm(k,n+)-)%P*ksm(k-,P-)%P;
int ans=;for (int k=;k<=n;k++) ans=(ans+f[k])%P;
cout<<ans;
return ;
}