Codeforces 453 A. Little Pony and Expected Maximum
来源:互联网 发布:get软件买到假鞋 编辑:程序博客网 时间:2024/06/05 14:54
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:
You can read about expectation using the following link: http://en.wikipedia.org/wiki/Expected_value
公式题
求期望值:
#include<iostream>#include<algorithm>#include<string>#include<iomanip>#include<cmath>#include<cstdio>using namespace std;int main(){long long n, m;cin >> m >> n;double sum = m;for(int i=m;i>=1;i--){sum-=pow(double(i-1)/(double) m,(double) n);}printf("%.8lf\n",sum);getchar();getchar();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
- p2p网络中的端的概念的区分
- java生成唯一序列号,UUID的应用
- 历届试题 危险系数
- 最优布线问题-SSL 1612
- ACM-递归递推练习D-汉诺塔系列1
- Codeforces 453 A. Little Pony and Expected Maximum
- QT之GUI学习笔记(十九)----QPainter
- Linux磁盘告警一般处理流程
- html 块级元素和行级元素
- QT串口读取数据
- 代码片段 URL
- svn安装并用eclipse集成
- IIS状态代码的含义
- 二叉链表的基本操作