QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 256 MB 총점: 100 해킹 가능 ✓

#15175. African

통계

Zag 是一款策略游戏《反恐精英:全球攻势》(简称 CSGO)的玩家。最近 CSGO 正在举办周年庆活动,并加入了一名强力角色 YUTS21。Zag 非常兴奋,因为他自 2008 年以来就一直在等待这名角色。为了获得这名新角色,Zag 需要先进行抽卡操作。

CSGO 的抽卡系统非常特殊。起初,获得 YUTS21 的概率为 $p$。如果 Zag 连续 $m$ 次没有获得 YUTS21,那么从第 $m + 1$ 次操作开始,每次操作获得 YUTS21 的概率将增加 $q$,直到他获得 YUTS21 为止。一旦他获得了 YUTS21,抽卡系统将会重置。即概率将变回 $p$,且操作次数将从 0 开始重新计算。

例如,假设 $p = 0.02$,$q = 0.02$ 且 $m = 50$,那么在前 50 次操作中,获得 YUTS21 的概率为 $0.02$。如果 Zag 连续 50 次没有获得 YUTS21,那么在第 51 次操作中,概率为 $0.04$,在第 52 次操作中为 $0.06$。以此类推,如果 Zag 运气非常差,连续 98 次都没有获得 YUTS21,那么在第 99 次操作中,概率将达到 $100\%$,他必定会获得 YUTS21。在此之后,抽卡系统将会重置。

Zag 已经在 CSGO 中花费了 3000 元(这是他本月所有的生活费),但他仍然没有获得任何 YUTS21。现在 Zag 想要计算,如果他进行 $n$ 次抽卡操作,他获得的 YUTS21 数量的期望值。但他太弱小无助了。他的朋友 Reb 劝说他联合其他玩家来解决这个问题。于是他找到了你。请帮助他解决这个问题。

我们可以证明,答案可以表示为最简分数 $\frac{x}{y}$,其中 $\gcd(x, y) = 1$。因此,你需要求出 $x y^{-1} \bmod 998244353$ 的值。可以证明,在给定的问题约束下,$y \bmod 998244353 \neq 0$。

输入格式

第一行也是唯一的一行包含四个整数 $n, m, p_0, q_0$ ($1 \le n, m \le 3000, 0 \le p_0, q_0 \le 1000000$),这意味着 $p_0 = 10^6 \times p$,$q_0 = 10^6 \times q$。

输出格式

输出一个整数,表示在 $n$ 次抽卡操作中获得的 YUTS21 数量的期望值模 $998244353$ 的结果。

样例

输入样例 1

2 1 500000 500000

输出样例 1

748683266

输入样例 2

7 1 100000 100000

输出样例 2

861153561

输入样例 3

100 50 20000 20000

输出样例 3

303920884

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.