QOJ.ac

QOJ

時間限制: 4 s 記憶體限制: 128 MB 總分: 100

#6360. Summation

统计

In 2016, Sister Jiayuan just learned about Stirling numbers of the second kind and was very happy. Now she wants to calculate 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)$ denotes the Stirling numbers of the second kind, with the recurrence relation: $$S(i, j) = j \times S(i - 1, j) + S(i - 1, j - 1), 1 \le j \le i - 1$$ The boundary conditions are: $S(i, i) = 1 (0 \le i)$, $S(i, 0) = 0 (1 \le i)$. Can you help her?

Input

The input contains only a single positive integer $n$.

Output

Output $f(n)$. Since the result can be very large, output $f(n) \pmod{998244353}$ (where $998244353 = 7 \times 17 \times 2^{23} + 1$).

Constraints

For 50% of the data, $1 \le n \le 5000$. For 100% of the data, $1 \le n \le 100000$.

Examples

Input 1

3

Output 1

87

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.