QOJ.ac

QOJ

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

#5032. 硬币游戏

统计

小 A 现在有 $n$ 个硬币排成一行,最开始都是正面朝下,并且从左到右依次编号为 $1,2,3, \cdots, n-1, n$。

小 A 决定玩一个游戏:小 A 会先进行 $k$ 次操作,每次选定两个正整数 $s, t$ 满足 $1 \leq s < t \leq n$ 然后翻转 $s$ 号和 $t$ 号硬币。

在 $k$ 次操作完成后,小 A 会选定一个值 $p(0 \leq p \leq n)$ 。我们假设左边 $p$ 个硬币 (编号为 $1 \sim p)$ 中朝上的硬币有 $a$ 个,右边 $n-p$ 个(编号为 $p+1 \sim n)$ 中朝上的有 $b$ 个。

除此之外,小A还有一个美观度函数 $H$ ,以及两个常数 $x, y$ 。

小 A 一局游戏的分数被定义为 $v a l=x^p y^{n-p} H(a)$ 。现在小 A 想求出所有游戏的分数和。

当然如果仅仅是求出所有游戏的分数和有点太无趣了,因此小A还规定了 $a, b$ 的具体值。我们定义 $F(x, y)$ 为所有满足 $a=x, b=y$ 的不同游戏的分数之和。两个游戏不同当且仅当某次操作的 $(s, t)$ 不同或者最后选择的 $p$ 不同。

小 A 并不仅仅满足于求出 $F(x, y)$ 。他又突发奇想,给了两个数 $r_a, r_b$ ,想让你求出 $ans_k=\sum_{i=0}^{r_a} F(i, r_b)$ ,其中 $k$ 表示进行了 $k$ 次操作。

小 A 除了是一个游戏爱好者之外,还是一个精益求精,奋发向上的人。因此他会要求你求出 $a n s_0, a n s_1, a n s_2, \cdots, a n s_{m-1}, a n s_m$ 。 答案对 $998\,244\,353$ 取模。

输入格式

第一行六个自然数 $n, x, y, r_a, r_b, m$ 。第二行 $r_a+1$ 个数,表示 $H(0), H(1), H(2), \ldots, H(r a-1), H(r a)$ 。

输出格式

一行 $m+1$ 个数,表示答案。

样例数据

样例 1 输入

5 1 4 1 1 4
1919 810

样例 1 输出

0 1231200 7387200 78796800 768268800

样例 2 输入

100 2 3 10 20 20
1 2 3 4 5 6 7 8 9 10 11

样例 2 输出

0 0 0 0 0 0 0 0 0 0 809274050 933560834 648523677 685804365 288106207 428246395 643105965 610311779 424132536 354030387 477940535

子任务

对于所有数据,保证 $0\leq n,x,y,H(i)< 998244353, 0\leq ra,rb,m\leq 10^5, ra+rb\leq n$,且 $x,y>0$。

子任务编号 特殊性质 分值
$1$ $n,m \leq 5\,000$ $10$
$2$ $ra, rb, m \leq 5\,000$ $20$
$3$ $ra, rb, m \leq 5 \times 10^4$,性质 A $20$
$4$ 性质 A $10$
$5$ $ra, rb, m \leq 5 \times 10^4$ $15$
$6$ $25$

性质 A:$H(x)$ 只有一个位置非零。

每个子任务可能会依赖数据范围为其子集的子任务。

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.