Jogging

TimeLimit:5000MS  MemoryLimit:524288KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
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.
Input
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$.
Output
$T$ lines, each line contains an irreducible fraction, indicating the answer.
SampleInput
3
18 16
18 6
18 8
SampleOutput
0/1
1/1
2/7
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: