Codeforces 453A Little Pony and Expected Maximum
来源:互联网 发布:mac粉底液专柜价格 编辑:程序博客网 时间:2024/05/20 00:12
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, the m-th face contains m 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 dice n times.
A single line contains two integers m and n (1 ≤ m, n ≤ 105).
Output a single real number corresponding to the expected maximum. The answer will be considered correct if its relative or absolute error doesn't exceed 10 - 4.
6 1
3.500000000000
6 3
4.958333333333
2 2
1.750000000000
Consider the third test example. If you've made two tosses:
- You can get 1 in the first toss, and 2 in the second. Maximum equals to 2.
- You can get 1 in the first toss, and 1 in the second. Maximum equals to 1.
- You can get 2 in the first toss, and 1 in the second. Maximum equals to 2.
- 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:
You can read about expectation using the following link: http://en.wikipedia.org/wiki/Expected_value
#include<stdio.h>double quickpow(double a,int b)//快速幂{ double r=1; while(b!=0) { if(b&1) r*=a; b=b>>1; a=a*a; } return r;}int main(){ int n,m,i; double sum,k; scanf("%d%d",&m,&n); sum=m; for(i=1;i<m;i++) { k=quickpow((m-i)*1.0/m,n); sum-=k; } printf("%.12lf\n",sum);}
- Codeforces 453A Little Pony and Expected Maximum
- Codeforces 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 最大值期望
- Codeforces 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
- Codeforces 453A Little Pony and Expected Maximum
- Codeforces 453A Little Pony and Expected Maximum
- CodeForces 453A Little Pony and Expected Maximum
- [概率DP] Codeforces 453A Little Pony and Expected Maximum
- Codeforces 453 A. Little Pony and Expected Maximum
- Little Pony and Expected Maximum CodeForces
- A. Little Pony and Expected Maximum
- A. Little Pony and Expected Maximum
- Codeforces 453A Little Pony and Expected Maximum 概率题Orz
- 一百个灯泡排成一排
- ios开发学习----swift学习之(一)基本运算
- ionic 实现下拉刷新上拉加载更多
- Python之socket
- warpAffine函数
- Codeforces 453A Little Pony and Expected Maximum
- 第一个基于Django的页面: Hello World
- 解题报告公主
- 响影响MySQL性能的相关因素
- log4j 数据库断连接解决办法
- linux下安装nginx-1.8.0
- Android高手进阶——Android ANR解决案例(内部资料)
- Oracle学习笔记1
- 属性动画