QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100

#8635. Circle

统计

There are $n(\geq 3)$ white balls arranged in a circle, numbered $1, 2, \dots, n$. You need to paint all these balls black. The operation is as follows:

  1. Choose a ball that has not been chosen before (either white or black) uniformly at random.
  2. Paint the chosen ball and its two adjacent balls black.
  3. If all white balls are painted black, the process ends.

Calculate the expected number of operations to paint all white balls black. The answer should be taken modulo 998244353.

Input

A single positive integer $n$, representing the number of white balls.

Output

A single integer representing the expected number of operations, modulo 998244353.

Examples

Input 1

4

Output 1

2

Note 1

After the first operation, only one white ball remains. Next, there are two black balls and one white ball that can be chosen; regardless of which one is chosen, all balls will be painted black.

Input 2

5

Output 2

499122179

Constraints

For $40\%$ of the data, $n \leq 10$.

For $100\%$ of the data, $n \leq 5000$.

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.