#P4091. [HEOI2016/TJOI2016] 求和

    ID: 3026 远端评测题 3000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学2016河北枚举,暴力容斥快速傅里叶变换 FFT快速数论变换 NTT天津

[HEOI2016/TJOI2016] 求和

Description

In 2016, Sister Jiayuan had just learned about the Stirling numbers of the second kind and was very happy.

Now she wants to compute the value of the following function:

$$f(n)=\sum_{i=0}^n\sum_{j=0}^i S(i,j)\times 2^j \times (j!)$$

S(i,j)S(i, j) denotes the Stirling numbers of the second kind, with the recurrence: $S(i, j) = j \times S(i - 1, j) + S(i - 1, j - 1), 1 \le j \le i - 1$.

Boundary conditions: S(i,i)=1(0i)S(i, i) = 1 (0 \le i), S(i,0)=0(1i)S(i, 0) = 0 (1 \le i).

Can you help her?

Input Format

The input contains a single positive integer nn.

Output Format

Output f(n)f(n). Since the result can be large, output f(n)f(n) modulo 998244353 (7×17×223+17 \times 17 \times 2^{23} + 1).

3
87

Hint

For 50% of the testdata, 1n5×1031 \le n \le 5 \times 10^3. For 100% of the testdata, 1n1051 \le n \le 10^5.

Translated by ChatGPT 5