P28246 [洛谷] [SHOI2012] Random Tree
提高+
题目描述

Problem Background

SHOI2012 D1T3

Problem Description

(Image reference: https://cdn.luogu.com.cn/upload/pic/6555.png)

Input Format

The input consists of a single line containing two positive integers q and n, representing the problem number and the number of leaf nodes, respectively.

Output Format

The output consists of a single line containing a real number d, rounded to six decimal places. If q = 1, d represents the expected value of the average depth of the leaf nodes. If q = 2, d represents the expected value of the depth of the tree.

Sample Input and Output

Sample Input #1

1 4

Sample Output #1

2.166667

Sample Input #2

2 4

Sample Output #2

2.666667

Sample Input #3

1 12

Sample Output #3

4.206421

Sample Input #4

2 12

Sample Output #4

5.916614

Notes

(Image references: https://cdn.luogu.com.cn/upload/pic/6556.png, https://cdn.luogu.com.cn/upload/pic/6557.png, https://cdn.luogu.com.cn/upload/pic/6558.png)

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 4
样例输出
2.166667