codeforces——Little Pony and Expected Maximum
2014-08-02 09:03
447 查看
/* 我们枚举每次选择最大数值的情况:m个数, 投掷n次 最大值是1: 1种 2: 2^n-1 3: 3^n-2^n ..... m: m^n-(m-1)^n 所以最后的结果=sum((k/m)^n - ((k-1)/m)^n) (1<=k<=m) 不要这样求(k^n/m^n)数据可能会很大! */ #include<iostream> #include<cstdio> #include<cmath> using namespace std; int main(){ int n, m; while(cin>>m>>n){ double sum, cur=pow(1.0/m, n), nt; sum=cur; for(int i=2; i<=m; ++i){ nt=pow(i*1.0/m, n); sum+=(nt-cur)*i; cur=nt; } printf("%.12lf\n", sum); } return 0; }
相关文章推荐
- Codeforces Div. 2 #259-C. Little Pony and Expected Maximum
- Codeforces 453 A. Little Pony and Expected Maximum
- Codeforces 453 A. Little Pony and Expected Maximum
- codeforces 453-A Little Pony and Expected Maximum
- CodeForces 453 A.Little Pony and Expected Maximum(快速幂)
- [Codeforces453A]Little Pony and Expected Maximum(概率期望+快速幂)
- Little Pony and Expected Maximum CodeForces - 453A (数学期望)
- Codeforces Round #259 (Div. 2) C. Little Pony and Expected Maximum
- Codeforces Round #259 (Div. 1) A. Little Pony and Expected Maximum 数学公式结论找规律水题
- C - Little Pony and Expected Maximum
- Little Pony and Expected Maximum
- A. Little Pony and Expected Maximum
- Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum
- Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum (数学期望)
- D-- Little Pony and Expected Maximum(CF--453A
- CF #259 div.2 C. Little Pony and Expected Maximum
- 神奇stl- - Little Pony and Expected Maximum
- Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum
- codeforces #259 DIV2 C题 Little Pony and Expected Maximum(容斥+快速幂+公式推导)
- C. Little Pony and Expected Maximum