Find the probability of getting a 1-bit number ?

By | February 19, 2017

Find the probability of getting a 1bit number ?

Find the probability of getting a 1-bit number after the following procedure is followed:

Initially a number x is chosen at random in a given range .After this we again choose a bit from x randomly?

Find the expected number of bit 1s if we randomly choose a number x in the given range?


 Input Format

The first line of input is the number of test cases T. Each test cases is a line contains 2 integers A and B separated by a space.

Output Format

For each test case output a line containing 2 float numbers separated by a space. The first one is the probability and the second one is the expected number. You should output the number accurate to 5 fractional digits.


1 <= T <= 200

1 <= A <= B <= 10^10

Sample Input


2 4

Sample Output




(10) (11) (100)

(1) So we got a one in :


(2) The expected 1 we have is


Time Limit:3.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB






Leave a Reply