World of Darkraft - 2

题意翻译

$\mathrm{Roma}$ 在游戏“World of Darkraft”(理论上应该是 World of darkcraft,MineCraft 的一个版本)找到一个新角色。 $\mathrm{Roma}$ 有 $k$ 种装备,一开始每种装备各有 $1$ 个,且每种装备的初始等级均为 $1$。游戏中可以靠打怪来获取新装备,总共有 $n$ 只怪兽,每打赢 $1$ 只怪兽后,$\mathrm{Roma}$ 会随机获得一种装备 $a\ (a\in [1,k])$,假设原有的 $a$ 装备的等级为 $t$,那么新获得的装备的等级为 $[1,t+1]$,$\mathrm{Roma}$ 会将新获得的装备和原来的装备中等级较高的装备留下,等级较低的装备卖出,卖出可获得的金币为该装备的等级。 问打完这 $n$ 只怪兽后,$\mathrm{Roma}$ 获得的金币的期望。 $(1 \le n \le 10^5,1\le k \le 100)$ 感谢 @ WJiannan 提供的翻译

题目描述

Roma found a new character in the game "World of Darkraft - 2". In this game the character fights monsters, finds the more and more advanced stuff that lets him fight stronger monsters. The character can equip himself with $ k $ distinct types of items. Power of each item depends on its level (positive integer number). Initially the character has one $ 1 $ -level item of each of the $ k $ types. After the victory over the monster the character finds exactly one new randomly generated item. The generation process looks as follows. Firstly the type of the item is defined; each of the $ k $ types has the same probability. Then the level of the new item is defined. Let's assume that the level of player's item of the chosen type is equal to $ t $ at the moment. Level of the new item will be chosen uniformly among integers from segment \[ $ 1 $ ; $ t+1 $ \]. From the new item and the current player's item of the same type Roma chooses the best one (i.e. the one with greater level) and equips it (if both of them has the same level Roma choses any). The remaining item is sold for coins. Roma sells an item of level $ x $ of any type for $ x $ coins. Help Roma determine the expected number of earned coins after the victory over $ n $ monsters.

输入输出格式

输入格式


The first line contains two integers, $ n $ and $ k $ ( $ 1<=n<=10^{5} $ ; $ 1<=k<=100 $ ).

输出格式


Print a real number — expected number of earned coins after victory over $ n $ monsters. The answer is considered correct if its relative or absolute error doesn't exceed $ 10^{-9} $ .

输入输出样例

输入样例 #1

1 3

输出样例 #1

1.0000000000

输入样例 #2

2 1

输出样例 #2

2.3333333333

输入样例 #3

10 2

输出样例 #3

15.9380768924