当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7016:Random Walk 2

题目描述
Penguin finds an directed complete graph with n vertices.

Notice that the graph has loops and no multiple edges.

Now he is going to walk on the graph randomly:

1.Suppose that he starts on the node $S$(now time $t=1$).

2.Then every time he will go from node $i$ to node $j$ with the probability $\displaystyle P[i][j]=\frac{W[i][j]}{\sum_{k=1}^nW[i][k]}(\sum_{k=1}^nW[i][k]>0)$.

3.If he is on the node $i$ at the time $t$ and also on the node $i$ at the time $t+1$,he will stay on node $i$ forever.

Penguin wants you to help him calculate the probability $A[i][j]$ that he starts on node $i$ and stops on node $j$.

Please compute $A[i][j]$ modulo $998244353$.

输入解释
The first line contains an integer $T(T \le 10)$. Then $T$ test cases follow.

For each test case the first line of input contains integer $n\in[1,300]$.

The $i$th of the following $n$ lines contains $n$ integers $W[i][j]\in[0,10^5]$.

$\sum n \le 2500$.
输出解释
For each test case there are $n$ lines.

The $i$th of $n$ lines contains $n$ integers $A[i][j]$ modulo $998244353$.

[Sample 1 Explanation]

For node $i$ there is a $\frac{1}{2}$ probability to stay on node $i$ and a $\frac{1}{2}$ probability to leave node $i$ .

So we can get

$$
A=\left(
\begin{array}{cc}
\frac{2}{3} & \frac{1}{3} \\
\frac{1}{3} & \frac{2}{3} \\
\end{array}
\right)
$$

Compute $A[i][j]$ modulo $998244353$

$$
A=\left(\begin{array}{cc}665496236 & 332748118 \\332748118 & 665496236 \\\end{array}\right)
$$
输入样例
2
2
1 1
1 1
2
1 1
1 0
输出样例
665496236 332748118
332748118 665496236
1 0
1 0

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7016

最后修改于 2021-10-23T19:11:04+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/4000MS(Java/Others) 262144/262144K(Java/Others)