题目链接

题意:一个m个面的骰子,抛掷n次,求这n次里最大值的期望是多少。(看样例就知道)

分析:

m个面抛n次的总的情况是m^n, 开始m==1时,只有一种

现在增加m = 2,  则这些情况是新增的那个的第一次的结果的后面最大的都是新增的,

之前的这些的分支也加上这个数,而且这个数是这一支里最大的,也就是说新增产生的结果

全都是m = 2的这个结果,所以用现在的总的情况减去之前的总的情况。

所以:

最大值是1: 1种
2: 2^n-1
3: 3^n-2^n
.....
m: m^n-(m-1)^n

然后根据求期望的公式乘起来,但是不能直接n次方,比如m^n会严重超出数据类型。

可以分解一下就行了。
所以最后的结果=sum((k/m)^n - ((k-1)/m)^n) (1<=k<=m)

 #include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#define LL long long
using namespace std; int main()
{
int i;
double ans, n, m;
while(cin>>m>>n)
{
ans = pow(1.0/m, n); for(i = ; i <= m; i++)
ans += (pow(i/m, n)-pow((i-)/m, n))*i; printf("%.4lf\n", ans);
}
return ;
}

Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum的更多相关文章

  1. Codeforces Round #259 (Div. 1) A. Little Pony and Expected Maximum 数学公式结论找规律水题

    A. Little Pony and Expected Maximum Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.c ...

  2. Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum (数学期望)

    题目链接 题意 : 一个m面的骰子,掷n次,问得到最大值的期望. 思路 : 数学期望,离散时的公式是E(X) = X1*p(X1) + X2*p(X2) + …… + Xn*p(Xn) p(xi)的是 ...

  3. Codeforces Round #259 (Div. 2) D. Little Pony and Harmony Chest 状压DP

    D. Little Pony and Harmony Chest   Princess Twilight went to Celestia and Luna's old castle to resea ...

  4. Codeforces Round #259 (Div. 2)-D. Little Pony and Harmony Chest

    题目范围给的很小,所以有状压的方向. 我们是构造出一个数列,且数列中每两个数的最大公约数为1; 给的A[I]<=30,这是一个突破点. 可以发现B[I]中的数不会很大,要不然就不满足,所以B[I ...

  5. Codeforces Round #259 (Div. 2)

    A. Little Pony and Crystal Mine 水题,每行D的个数为1,3.......n-2,n,n-2,.....3,1,然后打印即可 #include <iostream& ...

  6. Codeforces Round #259 (Div. 2)AB

    链接:http://codeforces.com/contest/454/problem/A A. Little Pony and Crystal Mine time limit per test 1 ...

  7. Codeforces Round #259 (Div. 2) D

    D. Little Pony and Harmony Chest time limit per test 4 seconds memory limit per test 256 megabytes i ...

  8. Codeforces Round #259 (Div. 1)A(公式)

    传送门 题意 给出m个面的骰子扔n次,取最大值,求期望 分析 暴力算会有重复,而且复杂度不对. 考虑m个面扔n次得到m的概率,发现只要减去(m-1)个面扔n次得到m-1的概率即可,给出example说 ...

  9. Codeforces Round #563 (Div. 2) E. Ehab and the Expected GCD Problem

    https://codeforces.com/contest/1174/problem/E dp 好题 *(if 满足条件) 满足条件 *1 不满足条件 *0 ///这代码虽然写着方便,但是常数有点大 ...

随机推荐

  1. Careercup - Facebook面试题 - 4713484755402752

    2014-05-02 00:30 题目链接 原题: Given two arrays of sorted integers, merge them keeping in mind that there ...

  2. 下拉刷新ListView实现原理

    (1)主要是onScroll()方法和onTouchEvent()方法,先是onTouchEvent()的ACTION_DOWN,然后是 ACTION_MOVE和onScroll()方法同时进行,最后 ...

  3. release下去除nslog宏

    #ifdef __OPTIMIZE__ #define NSLog(...) #endif 加在pch文件里面

  4. Ext学习-前后交互模式介绍

    在前后台交互模式的介绍中,实际上就是Store中Proxy相关的内容,比如Ajax提交. 所以详细的文档请参考: Ext学习-基础概念,核心思想介绍   中关于数据模型和MVC结构部分. 作者:sdj ...

  5. IIS7.5 自定义Html/shtml/htm...后缀映射

    以添加html后缀的文件的 映射为例: 1.打开iis管理器,点击 2.点击打开处理程序映射 3.添加托管处理程序映射 4.请求路径 *.html 类型: System.Web.UI.PageHand ...

  6. error C2061: syntax error : identifier '__RPC__out_xcount_part'

    朋友遇到的 把dx, windows sdk ,vs2010照着成功人士的配置好 应该就可以了

  7. uva 11076

    计算出每一位上数字i会出现的次数  累加 #include <cstdio> #include <cstdlib> #include <cmath> #includ ...

  8. uva 10912

    dp 记忆化搜索 #include <cstdio> #include <cstdlib> #include <cmath> #include <map> ...

  9. soap 路由

    下面主要通过项目实例来具体阐述如何实现wse路由和一些项目开发中的细节.本人水平有限,有不对的地方,请朋友们不吝赐教. 在开始项目之前,先了解一下路由的概念,所谓"路由",是指把数 ...

  10. linux源代码阅读笔记 linux文件系统(转)

    linux文件系统:   操作系统的文件数据除了文件实际内容外,还有非常多的属性,如文件权限(rwx)与文件属性(所有者.群组.时间参数等).   文件系统通常将这两部分数据存放在不同的块.权限属性放 ...