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

建议使用的浏览器:

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

6853:Jogging

题目描述
Notice:Don't output extra spaces at the end of one line.

Dodo bird is jogging on an infinite 2-d plane, starting from $(x_0, y_0)$. For a point$(x, y)$, it is regarded as good if and only if $\gcd(x,y)>1$.

Dodo bird will walk infinite steps on the plane under the following strategy:

Assume he is currently at $(x, y)$, let $S$ be the set of good points among $(x-1,y-1),(x-1,y),(x-1,y+1),(x,y-1),(x,y+1),(x+1,y-1),(x+1,y),(x+1,y+1)$, $z$ be the size of $S$. He has a probability of $\frac{1}{z+1}$ to stay in $(x, y)$, and he also has a probility of $\frac{z}{z+1}$ to move to a point in $S$. If he chooses to move, the probility of going to any point in $S$ is equal.

Define $p_t$ as the probability of coming back to $(x_0, y_0)$ after walking $t$ steps, please calculate $\lim_{t \to \infty}p_t$. It is guaranteed that the answer always exists.
输入解释
The first line contains an integer $T(1 \leq T \leq 1000)$, indicating the number of test cases.

Each test case has one line, which contains two integers $x, y(2 \leq x_0, y_0 \leq 10^{12})$, indicating the position of the start point. It is guaranteed that $\gcd(x_0,y_0) > 1$.
输出解释
$T$ lines, each line contains an irreducible fraction, indicating the answer.
输入样例
3
18 16
18 6
18 8
输出样例
0/1
1/1
2/7
来自杭电HDUOJ的附加信息
Recommend IceyWang

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

源链接: HDU-6853

最后修改于 2020-10-25T23:34:56+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/5000MS(Java/Others) 524288/524288K(Java/Others)