QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 524288 MB مجموع النقاط: 100

#13232. 期望

الإحصائيات

考虑一个数字 $1, 2, \dots, n$ 的随机排列 $(p_1, p_2, \dots, p_n)$。我们对值 $S = (X_2 + \dots + X_{n-2})^k$ 感兴趣,其中

$$X_i = \begin{cases} 1 & \text{若 } p_{i-1} < p_i > p_{i+1} \text{ 或 } p_{i-1} > p_i < p_{i+1} \\ 0 & \text{其他情况} \end{cases}$$

你需要求出 $S$ 的期望值,将其表示为既约分数 $P/Q$。当然,$P$ 和 $Q$ 可能非常大,因此只需输出 $P \cdot Q^{-1} \pmod{998244353}$ 的值。

输入格式

输入的第一行包含两个整数 $k$ 和 $n$ ($1 \le k \le 30, 3 \le n \le 10^8$)。

输出格式

输出一个整数,即 $P \cdot Q^{-1} \pmod{998244353}$ 的值。

样例

输入 1

1 6

输出 1

665496238

输入 2

2 11

输出 2

232923720

说明

在第一个样例中,期望值为 $8/3$,且 $3^{-1} = 332748118 \pmod{998244353}$,因此 $8 \cdot 3^{-1} = 665496238 \pmod{998244353}$。

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.