【CF 453A】 Little Pony and Expected Maximum (最大期望)
来源:互联网 发布:ib网络是什么意思啊 编辑:程序博客网 时间:2024/05/21 17:42
【CF 453A】 Little Pony and Expected Maximum (最大期望)
推一下可以发现掷出i的概率为 (i/m)^n-((i-1)/m)^n
这样递推求值即可 注意直接先求比再求幂 分子分母分开的话会爆 说了误差不超1e-4即可 不必担心精度
代码如下:
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#define ll long longusing namespace std;double pow(int i,int m,int b){ double ans = 1; double a = i*1.0/m; while(b) { if(b&1) ans *= a; a *= a; b >>= 1; } return ans;}int main(){ double x,pre,now,sum; int m,n,i; scanf("%d %d",&m,&n); sum = 0; pre = 0; for(i = 1; i <= m; ++i) { now = pow(i,m,n); sum += i*(now-pre); pre = now; } printf("%.12lf\n",sum); return 0;}
0 0
- 【CF 453A】 Little Pony and Expected Maximum (最大期望)
- CF 453A(Little Pony and Expected Maximum-若干次掷骰,最大那次期望-推公式)
- CF 453A(Little Pony and Expected Maximum-若干次掷骰,最大那次期望-推公式)
- Codeforces 453A Little Pony and Expected Maximum(期望)
- codeforces 453A Little Pony and Expected Maximum 最大值期望
- Codeforces 453A Little Pony and Expected Maximum 概率期望
- codeforces 453A Little Pony and Expected Maximum(期望)
- D-- Little Pony and Expected Maximum(CF--453A
- codeforces 453A. Little Pony and Expected Maximum (概率与期望+快速幂)
- A. Little Pony and Expected Maximum
- A. Little Pony and Expected Maximum
- Codeforces 453A Little Pony and Expected Maximum
- Codeforces 453A. Little Pony and Expected Maximum
- Codeforces 453 A. Little Pony and Expected Maximum
- Codeforeces 453A Little Pony and Expected Maximum
- codeforces 453-A Little Pony and Expected Maximum
- 【codeforces】 453A Little Pony and Expected Maximum
- Codeforces 453A Little Pony and Expected Maximum
- C++对象模型——执行期类型识别(第七章)
- Cocos2d-x中,Follow类的使用
- C#中OpenFileDialog获取文件名和文件路径的常用方法
- 运维规范:禁止使用hostname命令去查看主机名
- Cookie与Session
- 【CF 453A】 Little Pony and Expected Maximum (最大期望)
- case用法
- storm 远程过程调用及客户端调用
- 关于javaSE面向对象的一些小知识
- 从Eclipse转移到IntelliJ IDEA一点心得
- 黑马程序员——内部类,异常,Object类
- Python编程学习——生成器
- elasticsearch的研究与使用(二)Search API
- 彻底卸载MYSQL