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$ 嘅整數。即係輸出一個整數 $x$,令 $0\le x<M$ 同 $x\cdot q\equiv p\pmod M$。

例子

輸入格式 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.