QOJ.ac

QOJ

Limite de temps : 4 s Limite de mémoire : 512 MB Points totaux : 100

#2618. 休闲舞者

Statistiques

三位朋友正在研究随机游走。为了更深入地探讨这个课题,他们决定玩一个游戏。

最初,这三位朋友站在数轴上的整数点 $x_1, x_2, x_3$ 处。

游戏持续 $k$ 秒。

每一秒,从集合 $\{1, 2, 3\}$ 中等概率随机选择一个整数 $j$。然后,朋友 $j$ 以 $p$ 的百分比概率将其坐标增加 1,或以 $(100 - p)$ 的百分比概率将其坐标减少 1。

注意,多位朋友可以在初始时或游戏过程中站在同一个点上。

“跨度”(stretch)定义为包含所有三位朋友的数轴上最短线段的长度。

求 $k$ 秒后跨度的期望值,对 $998\,244\,353$ 取模(详见输出格式部分)。

输入格式

第一行包含三个整数 $x_1, x_2$ 和 $x_3$($-10^5 \le x_i \le 10^5$)。

第二行包含一个整数 $k$($1 \le k \le 2 \cdot 10^5$)。

第三行包含一个整数 $p$($0 \le p \le 100$)。

输出格式

输出 $k$ 秒后跨度的期望值,对 $998\,244\,353$ 取模。

形式化地,令 $M = 998\,244\,353$。可以证明,所求的期望跨度可以表示为不可约分数 $\frac{p}{q}$,其中 $p$ 和 $q$ 为整数且 $q \not\equiv 0 \pmod M$。输出等于 $p \cdot q^{-1} \pmod M$ 的整数。换句话说,输出一个满足 $0 \le x < M$ 且 $x \cdot q \equiv p \pmod M$ 的整数 $x$。

样例

输入 1

0 0 0
1
58

输出 1

1

输入 2

1 2 2
1
100

输出 2

332748119

输入 3

5 2 3
4
50

输出 3

160212060

说明

在第一个样例测试中,无论选择哪位朋友以及哪个方向,跨度都将等于 1。

在第二个样例测试中,实际的期望跨度为 $\frac{4}{3}$。

在第三个样例测试中,实际的期望跨度为 $\frac{271}{81}$。

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.