QOJ.ac

QOJ

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

#11718. 我想知道吗?

统计

你负责组织新一届的北极猴子竞赛(Arctic Competition for Monkeys,简称 ACM)。共有 $n$ 只猴子参加本次比赛,编号从 $1$ 到 $n$。每两只猴子之间都会进行一场只有一道题的比赛,比赛没有平局。对于任意 $i < j$,猴子 $i$ 击败猴子 $j$ 的概率为固定的 $p$。

你的经理要求你计算比赛的“娱乐系数”。你不知道这个系数是什么意思,你的经理也不知道,所以你决定给它一个相当奇怪的定义。

设 $f(k)$ 为存在一个恰好包含 $k$ 只猴子的集合,使得该集合中的每一只猴子都击败了该集合之外的每一只猴子的概率。

设 $g(k)$ 为一个递归定义的伪随机序列,如下所示: $$g(1) = 1;$$ $$g(i + 1) = (g(i))^2 + 2 \quad (\text{对于 } i \ge 2)。$$

然后,你将娱乐系数定义为以下值: $$\sum_{k=1}^{n-1} f(k) \cdot g(k)$$

因此,你需要求出在已知 $n$ 和 $p$ 的情况下该求和的值。或者,你真的想知道吗?

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 6 \cdot 10^5$),表示参赛者的数量。 第二行包含两个整数 $a$ 和 $b$ ($1 \le a < b \le 100$),表示分数 $p = \frac{a}{b}$ 的分子和分母。

输出格式

可以证明答案可以表示为 $\frac{P}{Q}$,其中 $P$ 和 $Q$ 是互质的整数,且 $Q \not\equiv 0 \pmod{998244353}$。 输出 $P \cdot Q^{-1}$ 对 $998244353$ 取模的结果。

样例

样例输入 1

4
2 6

样例输出 1

517608191

说明

在样例测试中,$f(1) = \frac{5}{9}$,$f(2) = \frac{35}{81}$,$f(3) = \frac{5}{9}$。此外,$g(1) = 1$,$g(2) = 3$,$g(3) = 11$。 因此,答案为 $\frac{5}{9} \cdot 1 + \frac{35}{81} \cdot 3 + \frac{5}{9} \cdot 11 = \frac{215}{27}$。

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.