CF453A.Little Pony and Expected Maximum

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.

The dice has m faces: the first face of the dice contains a dot, the second one contains two dots, and so on, the m-th face contains m dots. Twilight Sparkle is sure that when the dice is tossed, each face appears with probability . Also she knows that each toss is independent from others. Help her to calculate the expected maximum number of dots she could get after tossing the dice n times.

暮光闪闪曾与她的朋友们云宝黛西、苹果杰克和小蝶一起玩西洋双陆棋,但她总是输。回到城堡后,暮光闪闪开始对游戏中所用的骰子产生了兴趣。

该骰子有 mm 个面:第一个面上有 1 个点,第二个面上有 2 个点,依此类推,第 mm 个面上有 mm 个点。暮光闪闪确信,每次掷骰子时,每个面出现的概率均为 。此外,她还知道每次掷骰子的结果相互独立。请帮她计算掷骰子 nn 次后所能得到的点数最大值的期望值。

输入格式

A single line contains two integers m and n (1 ≤ m, n ≤ 105).

一行包含两个整数 mm 和 nn(1 ≤ m, n ≤ 1051 \leq m, n \leq 10^5)。

输出格式

Output a single real number corresponding to the expected maximum. The answer will be considered correct if its relative or absolute error doesn't exceed 10  - 4.

输出一个实数,表示期望的最大值。若答案的相对误差或绝对误差不超过 10−410^{-4},则视为正确。

输入输出样例

  • 输入#1

    6 1

    输出#1

    3.500000000000
  • 输入#2

    6 3

    输出#2

    4.958333333333
  • 输入#3

    2 2

    输出#3

    1.750000000000

说明/提示

Consider the third test example. If you've made two tosses:

  1. You can get 1 in the first toss, and 2 in the second. Maximum equals to 2.
  2. You can get 1 in the first toss, and 1 in the second. Maximum equals to 1.
  3. You can get 2 in the first toss, and 1 in the second. Maximum equals to 2.
  4. You can get 2 in the first toss, and 2 in the second. Maximum equals to 2.

The probability of each outcome is 0.25, that is expectation equals to:

You can read about expectation using the following link: http://en.wikipedia.org/wiki/Expected_value

考虑第三个测试样例。如果你进行了两次投掷:

  1. 第一次投掷得到 1,第二次投掷得到 2,最大值为 2。
  2. 第一次投掷得到 1,第二次投掷得到 1,最大值为 1。
  3. 第一次投掷得到 2,第二次投掷得到 1,最大值为 2。
  4. 第一次投掷得到 2,第二次投掷得到 2,最大值为 2。

每种结果出现的概率均为 0.25,因此期望值为:

你可通过以下链接了解期望值的概念:http://en.wikipedia.org/wiki/Expected_value

输入解题思路,AI测评打分。不知道怎么写?

首页