7575: Jogging

内存限制:512 MB 时间限制:5 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:20 通过:12

题目描述

Notice:Don't output extra spaces at the end of one line.

Dodo bird is jogging on an infinite 2-d plane, starting from (x0,y0). 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 1z+1 to stay in (x,y), and he also has a probility of zz+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 pt as the probability of coming back to (x0,y0) after walking t steps, please calculate limt→∞pt. It is guaranteed that the answer always exists.

输入格式

The first line contains an integer T(1≤T≤1000), indicating the number of test cases.

Each test case has one line, which contains two integers x,y(2≤x0,y0≤1012), indicating the position of the start point. It is guaranteed that gcd(x0,y0)>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