首页 > 其他 > 详细

codeforces C. Little Pony and Expected Maximum

时间:2015-03-16 22:29:31      阅读:300      评论:0      收藏:0      [点我收藏+]

题意:一个筛子有m个面,然后扔n次,求最大值的期望;

思路:最大值为1 有1种,2有2n-1种,  3有3n -2n 种   所以为m的时有mn -(m-1)n 种,所以分别求每一种的概率,然后乘以这个值求和就可以。

技术分享
 1 #include <cstdio>
 2 #include <cstring>
 3 #include <iostream>
 4 #include <cmath>
 5 #include <algorithm>
 6 using namespace std;
 7 
 8 int n,m;
 9 
10 int main()
11 {
12     cin>>m>>n;
13     double x=pow(1.0/m,n);
14     double ans=x;
15     for(int i=2; i<=m; i++)
16     {
17         double xx=pow(i*1.0/m,n);
18         ans+=(xx-x)*i;
19         x=xx;
20     }
21     printf("%.12lf\n",ans);
22     return 0;
23 }
View Code

 

codeforces C. Little Pony and Expected Maximum

原文:http://www.cnblogs.com/fanminghui/p/4342824.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!