QOJ.ac

QOJ

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

#2618. 隨性舞者

Statistics

三位朋友正在研究隨機漫步。為了更深入了解這個主題,他們決定玩一個遊戲。

一開始,三位朋友站在數線上的整數點 $x_1,x_2,x_3$。

遊戲持續 $k$ 秒。

每秒鐘,從集合 $\{1,2,3\}$ 中等機率隨機選出一個整數 $j$。接著,第 $j$ 位朋友以 $p\%$ 的機率將自己的座標增加 $1$,或以 $(100-p)\%$ 的機率將自己的座標減少 $1$。

請注意,無論在一開始還是遊戲過程中,都可以有多位朋友站在同一個點上。

跨度定義為數線上包含三位朋友的最短線段的長度。

求 $k$ 秒後跨度的期望值,對 $998\,244\,353$ 取模(詳見輸出格式)。

輸入格式

第一行包含三個整數 $x_1,x_2,x_3$($-10^5\le x_i\le10^5$)。

第二行包含一個整數 $k$($1\le k\le2\cdot10^5$)。

第三行包含一個整數 $p$($0\le p\le100$)。

輸出格式

輸出 $k$ 秒後跨度的期望值,對 $998\,244\,353$ 取模。

形式化地說,令 $M=998\,244\,353$。可以證明,所求的跨度期望值可表示為最簡分數 $\frac pq$,其中 $p$ 和 $q$ 為整數,且 $q\not\equiv0\pmod M$。輸出等於 $p\cdot q^{-1}\bmod 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$。

在第二個範例中,實際的跨度期望值為 $\frac43$。

在第三個範例中,實際的跨度期望值為 $\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.