This page is still under construction.

Parts of this page are still being built. What you see may change.

DotA Quals

Time limit1sMemory limit256 MB

Summary
Given 2^n players and Idned ranked k-th, compute the expected number of rounds he survives when opponents are randomly paired each round and the higher rating always wins.
Level

Medium7 of 10

Topics
Probability, Combinatorics, Math, Dynamic programming
Solved
No attempts yet

Problem

Instead of studying for the coming exams, a student with the nickname "Idned" has decided to enter an open qualification for a huge DotA (Development of the Algorithms) tournament. The qualification is a single-elimination tournament with 2n2^n participants, and Idned is one of them. There are nn rounds in total. Before each round, all remaining participants are randomly divided into pairs, with every possible division equally likely. In each pair the two participants play, and the loser quits the tournament and does not play in later rounds.

Every participant has a unique rating, and Idned's rating is the kk-th highest. Idned is sure that the outcome of each game is fully determined by the two participants' ratings, with the higher rating winning. Under this assumption, can you determine the expected number of rounds in which Idned takes part?

Input

The input contains two integers nn and kk: the total number of rounds and Idned's position in the overall rating (1≤n≤101 \le n \le 10; 1≤k≤2n1 \le k \le 2^n).

Output

Output the expected number of rounds.

Your answer must be correct to within an absolute or relative error of 10−910^{-9}. Formally, let your answer be aa and the jury's answer be bb. Your answer is considered correct if ∣a−b∣max⁡(1,∣b∣)≤10−9\frac{|a-b|}{\max(1, |b|)} \le 10^{-9}.

Examples2

  1. Example 1

    Input
    2 2
    
    Expected output
    1.666666666667
    
  2. Example 2

    Input
    3 5
    
    Expected output
    1.457142857143