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, them-th face containsm 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 dicen times.

Input

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

Output

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

Sample Input

Input
6 1
Output
3.500000000000
Input
6 3
Output
4.958333333333
Input
2 2
Output
1.750000000000

Hint

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:

题目大意:

求出最大点数的期望(这两个字被平均取代后瞬间没有高尚感- -)。

思路:

若有5个的6面骰子出现最大点为1的次数为1^5,出现最大点为2的的次数为2^5-1^5,以此来推出最大点出现的次数为i^5-(i-1)^5;

求出最大值得期望,由演示样例能够得到 p = ( (1^n-0^n)*1 + (2^n-1^n)*2 。

。 +(m^n - (m-1)^n)*m ) / m^n ;将m^n带入
终于得到 p = m - ((m-1)/m)^n + ((m-2)/m)^n。

。。+(1/m)^n ;

#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<algorithm>
#define LL long long
int a[1010];
using namespace std;
int main()
{
    LL s;
    int i,j,n,m,k,inr,x;
    double sum;
    while(scanf("%d%d",&m,&n)!=EOF)
    {
        sum=0;
        for(i=1;i<=m;i++)
        {
            sum+=i*(pow(i*1.0/m,n)-pow((i-1)*1.0/m,n));<span id="transmark"></span>
        }
        printf("%.12lf\n",sum);
    }
}

CodeForces 453A的更多相关文章

  1. CodeForces - 453A Little Pony and Expected Maximum

    http://codeforces.com/problemset/problem/453/A 题目大意: 给定一个m面的筛子,求掷n次后,得到的最大的点数的期望 题解 设f[i]表示掷出 <= ...

  2. CodeForces 453A 概率题

    Description Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter ...

  3. 嘴巴题9 Codeforces 453A. Little Pony and Expected Maximum

    A. Little Pony and Expected Maximum time limit per test 1 second memory limit per test 256 megabytes ...

  4. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  7. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  8. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  9. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

随机推荐

  1. BZOJ 2754 [SCOI2012]喵星球上的点名 (AC自动机+map维护Trie树)

    题目大意:略 由于字符集大,要用map维护Trie树 并不能用AC自动机的Trie图优化,不然内存会炸 所以我用AC自动机暴跳fail水过的 显然根据喵星人建AC自动机是不行的,所以要根据问题建 然而 ...

  2. IDEA Maven 打包运行 jar java.io.FileNotFoundException: 问题?

    当 使用 idea maven 将项目打包运行的时候,能够成功运行,但是总会跑到 xxx\xxx\lib 下 找jar包 如下异常: java.io.FileNotFoundException: D: ...

  3. (七)u-boot2013.01.01 for s5pv210:《u-boot启动流程》

    转载请注明地址:http://blog.csdn.net/zsy2020314/article/details/9824035 1.关于启动流程 1.1 启动阶段分为3个,bl0,bl1,bl2.下面 ...

  4. Unity 常用常找的东西存放

    本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/details/50483316 作者:car ...

  5. Vue 做项目经验

    Vue 做项目经验 首先需要知道最基本的东西是: Vue 项目打包:npm run build Vue生成在网页上看的端口:npm run dev 修改端口号的地方在: config文件夹下index ...

  6. PatentTips - Cross-domain data transfer using deferred page remapping

    BACKGROUND OF THE INVENTION The present invention relates to data transfer across domains, and more ...

  7. Oracle sql 子字符串长度判断

    Oracle sql 子字符串长度判断 select t.* from d_table t ,) ,instr(t.col,; 字符串的前两位都是数字: select * from d_table t ...

  8. hdoj--4857--逃生(拓扑排序+反向建图)

    逃生 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  9. xBIM 基础09 WeXplorer 基本应用

    系列目录    [已更新最新开发文章,点击查看详细]  在本教程中,将学习如何创建最基本和最直接的查看器. 除了展示建筑模型外,不做其他任何操作.它将只使用内置导航,但是不会对按钮做出事件响应. &l ...

  10. 启动项目报错:org.springframework.beans.factory.UnsatisfiedDependencyException

    dubbo项目: 启动项目报错:(web端) org.springframework.beans.factory.UnsatisfiedDependencyException: Error creat ...