Problem:
Score : 300 points

Problem Statement

Snuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:

Throw the die. The current score is the result of the die.

As long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.

The game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.

You are given N and K. Find the probability that Snuke wins the game.

Constraints

1 ≤ N ≤ 10^5

1 ≤ K ≤ 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.

Sample Input 1

3 10

Sample Output 1

0.145833333333

If the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^4 = \frac{1}{48}.

If the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^3 = \frac{1}{24}.

If the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^2 = \frac{1}{12}.

Thus, the probability that Snuke wins is \frac{1}{48} + \frac{1}{24} + \frac{1}{12} = \frac{7}{48} \simeq 0.1458333333.

Sample Input 2

100000 5

Sample Output 2

0.999973749998

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtcoderC
{
    class Program
    {
        /*static void Main(string[] args)
        {
        }*/
        //ABC132C
        //全探索法
        /*static void Main()
        {
            BigInteger N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int min = input.Min();
            int max = input.Max();
            int countARC = 0;
            int countABC = 0;
            int Answer = 0;
            for (int i = min; i <= max; i++)
            {
                countABC = 0;
                countARC = 0;
                foreach (int n in input)
                {
                    if (n > i)
                    {
                        countARC++;
                    }
                    else
                    {
                        countABC++;
                    }
                }
                if (countABC == countARC)
                {
                    Answer++;
                }
            }
            Console.WriteLine(Answer);
        }*/
        //2回目
        /*static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(input);
            int min = input[(N / 2) - 1];
            int max = input[N / 2];
            Console.WriteLine(max - min);
        }*/

        //ABC131C
        //ユーグリッドの互除法の応用
        /*static void Main()
        {
            BigInteger[] input = Console.ReadLine().Split().Select(BigInteger.Parse).ToArray();
            BigInteger A = input[0];
            BigInteger B = input[1];
            BigInteger C = input[2];
            BigInteger D = input[3];
            BigInteger ans = (B / C) + (B / D);           
            //最小公倍数
            var ans2 = C * D / lcm(C, D);
            BigInteger ans3 = B / ans2;
            var BB = B - ans + ans3;
            ans = (A - 1) / C + (A - 1) / D;
            ans3 = (A - 1) / ans2;
            var AA = (A - 1) - ans + ans3;
            Console.WriteLine(BB - AA);
            
        }
        static public BigInteger lcm(BigInteger a, BigInteger b)
        {
            var r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }*/

        //129C
        //動的計画法
        //TLEになる時間がかかり過ぎる
        /*static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            List<int> ttt = new List<int>();
            for (int i = 0;i < M;i++)
            {
                var temp = int.Parse(Console.ReadLine());
                ttt.Add(temp);
            }
            int[] dparray = new int[N+2];
            dparray[N] = 1;
            dparray[N - 1] = 1;
            for (int i = N-1; i >= 0; i--)
            {
                if (ttt.Contains(i))
                {
                    dparray[i] = 0;
                }
                dparray[i] = (dparray[i + 1] + dparray[i + 2]) % 1000000007;
            }
            Console.WriteLine(dparray[0]);
        }*/
        //ABC128
        /*static void Main()
        {

        }*/
        //ABC134A
        /*static void Main()
        {
            int r = int.Parse(Console.ReadLine());
            var ans = 3 * r * r;
            Console.WriteLine(ans);
        }*/
        //ABC134B
        /*static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int D = input[1];
            int count = 0;
            int ans = N;
            while (true)
            {
                ans = ans - (D * 2 + 1);
                count++;
                if (ans <= 0)
                {
                    break;
                }
            }
            Console.WriteLine(count);
        }*/
        //ABC134C
        /*static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            List<int> array = new List<int>();
            for (int i =0;i<N; i++)
            {
                array.Add(int.Parse(Console.ReadLine()));
            }
            List<int> ans = new List<int>();
            int max = array.Max();
            var temp  = new List<int>();
            foreach (int n in array)
            {
                 temp.Add(n);
            }
            temp.Sort();
            temp.Reverse();
            int second = temp[1];

            foreach (int nn in array)
            {
                if (nn == max)
                {
                    Console.WriteLine(second);
                }
                else
                {
                    Console.WriteLine(max);
                }
            }
        }*/
        //134ABCD
        /*static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int count = 0;
            int ans = 0;
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0;i<N;i++)
            {
                for (int j =0;j<N; j++)
                {
                    if ((j+1)%(i+1)==0)
                    {
                        count += input[j];
                    }
                }
                if (count % 2 == input[i])
                {
                    ans++;
                }
                count = 0;
            }
            if (ans != 0)
            {

            }
        }*/
        //AGC036
        /*static void Main()
        {
            long S = long.Parse(Console.ReadLine());
            long X1 = 1000000000;
            long Y1 = 0;
            /*while (true)
            {
                Y1 = S / X1 + S % X1;
            }
            Y1 = S / X1 + S % X1;
            Console.WriteLine("0 0 " + X1 + " 0 0 " + Y1); 
            /*int tempX = 0;
            List<long> ss = new List<long>();
            while (tempX < S)
            {
                var ans = S % tempX;
                if (ans == 0)
                {
                    ss.Add(ans);
                }
                tempX++;
            }
            Console.WriteLine(tempX);*/
        /*long X1 = 0;
        long Y1 = 1;
        while (true)
        {
            X1 = S % Y1;
            if (X1 <= 1000000000)
            {
                break;
            }
            Y1++;
        }
        Console.WriteLine("0 0 "+X1+" 0 0 "+Y1);
    }*/
        //ABC82A
        /*static void Main()
        {
            double[] input = Console.ReadLine().Split().Select(double.Parse).ToArray();
            double a = input[0];
            double b = input[1];
            double sum = (a + b) / 2;
            Console.WriteLine(Math.Ceiling(sum));

        }*/
        //ABC128C
        /*static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            int ans = 0;
            List<int[]> K = new List<int[]>();
            for (int i = 0;i<M;i++)
            {
                var temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                K.Add(temp);
            }
            int[] P = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] light = new int[M];
            for (int i = 0;i < Math.Pow(2,N);i++)
            {
                var isrow = 0;
                var temp = int.Parse(Convert.ToString(i, 2)).ToString("0000000000");
                for (int j  =0;j < M;j++)
                {
                    var ison = 0;
                    for (int k = 0; k < K[j][0];k++)
                    {
                        var index = K[j][k] - 1;
                        if (temp[9-index] == '1')
                        {
                            ison++;
                        }
                    }
                    if (ison % 2 == P[j])
                    {
                        isrow++;
                    }
                    else
                    {
                        break;
                    }
                }
                if (isrow == M)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);*/
        /*nt[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = input[0];
        int b = input[1];
        var temp = a * b % 2;
        if (temp == 0)
        {
            Console.WriteLine("even");
        }
        else
        {
            Console.WriteLine("odd");
        }
    }*/
        //ABC127C 
        /*static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            List<int[]> gate = new List<int[]>();
            for (int i = 0; i < M; i++)
            {
                var temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                gate.Add(temp);
            }
            if (M == 1)
            {
                Console.WriteLine(N);

            }
            else
            {
                List<int> card = new List<int>();
                for (int i = gate[0][0]; i <= gate[0][1]; i++)
                {
                    card.Add(i);
                }

                for (int j = 1; j < gate.Count; j++)
                {
                    List<int> ans = new List<int>();
                    var count = 0;
                    for (int i = gate[j][0]; i <= gate[j][1]; i++)
                    {
                        if (card.Contains(i))
                        {
                            count++;
                            ans.Add(i);
                        }
                    }
                    if (count == 0)
                    {
                        break;
                    }
                    card = new List<int>(ans);
                }
                Console.WriteLine(card.Count());
            }
        }*/
        //127C Revenge TLE
        /*static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            List<int[]> gate = new List<int[]>();
            for (int i = 0; i < M; i++)
            {
                var temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                gate.Add(temp);
            }
            int Ans = 0;
            for (int i =1;i<=N;i++)
            {
                var count = 0;
                for (int j = 0;j < gate.Count;j++)
                {
                    if (gate[j][0] <= i && i <= gate[j][1])
                    {
                        count++;
                    }  
                }
                if (count == gate.Count)
                {
                    Ans++;
                }
            }
            Console.WriteLine(Ans);
        }*/
        //127C RevengeVer2
        /*static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            List<int[]> gate = new List<int[]>();
            for (int i = 0; i < M; i++)
            {
                var temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                gate.Add(temp);
            }
            List<int> Max = new List<int>();
            List<int> Min = new List<int>();
            for (int i =0;i< M;i++)
            {
                Max.Add(gate[i][1]);
                Min.Add(gate[i][0]);
            }
            int max = Max.Min();
            int min  = Min.Max();
            if (min <= max)
            {
                Console.WriteLine(max - min + 1);
            }
            else
            {
                Console.WriteLine("0");
            }
        }*/
        //ABC126C
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            double ans = 0.0;
            for (int i = 1; i<= N;i++)
            {
                double tempP = (double)1 / N;
                int point = i;
                while (point<M)
                {
                    tempP = tempP * 1 / 2;
                    point *= 2;
                }
                ans += tempP;
            }
            Console.WriteLine(ans);
        }
    }
}