Lucky Game - Lucky Game
Dữ liệu vào: standard input
Dữ liệu ra: standard output
Giới hạn thời gian: 1.0 giây
Giới hạn bộ nhớ: 256 megabyte
Đăng bởi: chandoi

Chú ý: bộ test do mình make(có thể có lỗi), không phải bộ test chính thức của kì thi

Thanh likes lucky games and today he is playing a new game: First he will be given 2 numbers A, B. There are B-A+1 boxes and each box is marked with a distinct number from A to B. Each box contains some balls, there are 2 colors of ball: black and white. The number of black and white balls in each box is depended on its marked number. Precisely, assuming that a box is marked with number V, if we convert number V into its binary presentation and remove any leading zero bits, then the number of 1-bits equals to the number of black balls and the number of 0-bits equals to the number of white balls. For example, a box marked with number 4 contains 1 black ball and 2 white balls as its binary presentation is 100.

The rule is simple: First Thanh randomly choose a box among B-A+1 boxes, after that he randomly choose a ball inside that box. If that ball is black then he wins, otherwise he loses. Thanh wants to know the probability that he can win this game.

Input

Input starts with the number of tests - T (1 ≤ T ≤ 100). Then T tests follow. Each test consists of 2 numbers Aand B (1 ≤ A ≤ B ≤ 1018)

Output

For each test in the input, output the probability that Thanh can win, with exactly 3 digits after decimal place.

• input
2
2 3
4 7
output
0.750
0.667
Bài tập mới
Coder tích cực