Codeforces 453A Little Pony and Expected Maximum
来源:互联网 发布:南京市网络问政平台 编辑:程序博客网 时间:2024/06/10 11:56
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 mdots. 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:
#include<stdio.h>#include<math.h>int main(){int n,m;double sum;scanf("%d%d",&m,&n);sum=m;for(int i=1;i<m;i++){sum-=pow((double)1.0-(double)i/m,(double)n);}printf("%.12lf\n",sum);return 0;}
- 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
- 用栈实现计算器
- JSP
- 【iOS开发技术】Block的使用(一)
- 【iOS开发技术】Block的使用(二)
- PHP开发环境搭建
- Codeforces 453A Little Pony and Expected Maximum
- 【iOS开发技术】NSPredicate谓词的用法 数组过滤
- svn报错
- Display XML in a javadoc
- hdu 1060 leftmost
- 迷你播放器--综述
- 病狗问题以及帽子颜色那个题
- 爱到深处无言
- hdu 1060 2014731