Mani and Pane

0

0 votes
Problem

Mani wants to eat chocolates, but her brother Pane does not give her the chocolates easily. Pane being a mathematician wants to teach Mani an important concept. Pane makes Mani stand on an infinite straight line. He marks all integers at equal divisions on the line and places chocolates on the integer X.

Initially Mani is on an integer Z. Mani can jump forward or backward from any general integer K. Pane being a mischievous brother puts a constraint that Mani can jump forward or backward only A, B or C integers i.e from any general integer K there are 6 possible moves (K+A, K-A, K+B, K-B, K+C, K-C). Pane gives Mani the liberty to choose distinct A, B and C in the range [1,100]. Find the probability that Mani succeeds in reaching the chocolates. Note that Mani is really clever and if she can reach the chocolates, she will.

Input :

First line contains an integer T containing test cases. Each test case consists of a single line with two integers X and Z.

Output :

A single line for each test case having the answer rounded off to exactly 6 digits after the decimal.

Constraints :

1<=T<=105

1<=X,Z<=2 * 1018

1<=A,B,C<=100

Author : Sayan

Tester : Shreyans

(By IIT Kgp HackerEarth Programming Club)

Sample Input
3
2 10
15758 29586685
1000 1000000000
Sample Output
0.956092
0.839450
0.999716
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?