QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#4610. 小 Y 和恐怖的奴隶主

统计

"A fight? Count me in!" 要打架了,算我一个。

"Everyone, get in here!" 所有人,都过来!


小Y是一个喜欢玩游戏的OIer。一天,她正在玩一款游戏,要打一个Boss。

虽然这个Boss有 $10^{100}$ 点生命值,但它只带了一个随从——一个只有 $m$ 点生命值的“恐怖的奴隶主”。

这个“恐怖的奴隶主”有一个特殊的技能:每当它被扣减生命值但没有死亡(死亡即生命值 $\leq 0$),且Boss的随从数量小于上限 $k$,便会召唤一个新的具有 $m$ 点生命值的“恐怖的奴隶主”。

现在小Y可以进行 $n$ 次攻击,每次攻击时,会从Boss以及Boss的所有随从中的等概率随机选择一个,并扣减 $1$ 点生命值,她想知道进行 $n$ 次攻击后扣减Boss的生命值点数的期望。为了避免精度误差,你的答案需要对 $998244353$ 取模。

输入格式

从标准输入读入数据。

输入第一行包含三个正整数 $T, m, k$,$T$ 表示询问组数,$m, k$ 的含义见题目描述。

接下来 $T$ 行,每行包含一个正整数 $n$,表示询问进行 $n$ 次攻击后扣减Boss的生命值点数的期望。

输出格式

输出到标准输出。

输出共 $T$ 行,对于每个询问输出一行一个非负整数,表示该询问的答案对 $998244353$ 取模的结果。

可以证明,所求期望一定是一个有理数,设其为 $p / q$($\mathrm{gcd}(p,q) = 1$),那么你输出的数 $x$ 要满足 $p \equiv qx \pmod{998244353}$。

样例一

input

3 2 6
1
2
3

output

499122177
415935148
471393168

explanation

对于第一次询问,第一次攻击有 $\frac{1}{2}$ 的概率扣减Boss的生命值,有 $\frac{1}{2}$ 的概率扣减随从的生命值,所以答案为 $\frac{1}{2}$。$1 \equiv 2 * 499122177 \pmod{998244353}$。

对于第二次询问,如果第一次攻击扣减了Boss的生命值,那么有 $\frac{1}{2}$ 的概率第二次攻击仍扣减Boss的生命值,有 $\frac{1}{2}$ 的概率第二次攻击扣减随从的生命值;如果第一次攻击扣减了随从的生命值,那么现在又新召唤了一个随从(“恐怖的奴隶主”),于是有 $\frac{1}{3}$ 的概率第二次攻击扣减Boss的生命值,有 $\frac{2}{3}$ 的概率第二次攻击扣减随从的生命值。所以答案为 $\frac{1}{2}*\frac{1}{2}*2+\frac{1}{2}*\frac{1}{2}*1+\frac{1}{2}*\frac{1}{3}*1+\frac{1}{2}*\frac{2}{3}*0 = \frac{11}{12}$。$11 \equiv 12 * 415935148\pmod{998244353}$。

样例二

见下发文件。

该组样例的数据范围(除询问组数 $T$ 外)同第7、8个测试点。

提示

题目顺序可能与难度无关。

限制与约定

在所有测试点中,$1 \leq T \leq 1000, 1 \leq n \leq {10}^{18}, 1 \leq m \leq 3, 1 \leq k \leq 8$。

各个测试点的分值和数据范围如下:

测试点编号分值$T=$$n\leq$$m=$$k=$
13101011
2828
37${10}^{18}$3
4127
5302035
6105006
7102007
851000
9101008
105500
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.