QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100

#8171. 可乐

统计

Alice 有一个最喜欢的排列 $P = (P_1, P_2, \dots, P_N)$,它是 $(1, 2, \dots, N)$ 的一个排列。Bob 发现如果他猜中了 $P$,他就能从 Alice 那里得到一瓶可乐。因此,Bob 决定向 Alice 提问以猜出 $P$。

Bob 最多可以提出 $M$ 次以下问题: * 选择一个 $(1, 2, \dots, N)$ 的排列 $Q = (Q_1, Q_2, \dots, Q_N)$,并询问 Alice 她最喜欢的排列是否为 $Q$。

这里满足 $M \le N$。

Alice 将通过以下方式回答 Bob 的问题: 如果 $P = Q$,Alice 会给 Bob 一瓶可乐。 如果 $P \neq Q$,Alice 会告诉 Bob 满足 $P_i \neq Q_i$ 的最小下标 $i$。

例如,如果 $P = (4, 3, 2, 1)$ 且 Bob 询问 $Q = (4, 3, 1, 2)$,Alice 会告知 Bob 存在一个下标 $i$ 使得 $P_i \neq Q_i$,且满足该条件的最小下标 $i$ 为 $3$。

注意,即使 Bob 在第 $M$ 次提问后确定了 $P$,他也无法获得可乐。

最初,Bob 对 $P$ 一无所知。请计算 Bob 从 Alice 那里获得可乐的最大概率,并将该概率对 $998244353$ 取模后输出。

概率取模定义 $998244353$

可以证明本题所求的概率总是一个有理数。此外,在本题的数据范围内,保证当所求概率表示为最简分数 $\frac{y}{x}$ 时,$x$ 不能被 $998244353$ 整除。在这种情况下,存在唯一的 $0 \le z < 998244353$ 满足 $y \equiv xz \pmod{998244353}$,输出该 $z$ 即可。

输入格式

输入通过标准输入给出,格式如下:

$N \ M$

  • 输入中的所有值均为整数。
  • $1 \le M \le N \le 10^7$

输出格式

输出答案。

样例

输入格式 1

2 1

输出格式 1

499122177

说明

在第一个样例中,由于只允许提问一次,且 $P$ 有两种可能的排列,Bob 获得可乐的概率为 $\frac{1}{2}$。

注意,即使 Bob 在第一次提问时猜错了,他仍然可以确定 $P$,但他无法获得可乐。

输入格式 2

1 1

输出格式 2

1

说明

在第二个样例中,Bob 总能在第一次提问时获得可乐。

输入格式 3

167 91

输出格式 3

469117530

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.