codeforces 453A
来源:互联网 发布:恒大淘宝 编辑:程序博客网 时间:2024/06/11 15:46
A. Little Pony and Expected Maximum
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.
Input
A single line contains two integers m and n (1 ≤ m, n ≤ 105).
Output
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.
Examples
input
6 1
output
3.500000000000
input
6 3
output
4.958333333333
input
2 2
output
1.750000000000
Note
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:
水概率不多bb
#include<iostream>#include<queue>#include<cmath>#include<cstdio>#include<algorithm>using namespace std;double ksm(double ds, int zs){ double fs = 1; while (zs) { if (zs & 1)fs *= ds; ds *= ds; zs >>= 1; } return fs;}double tu[100001];int main(){ int m, n; cin >> m >> n; for (int a = 1; a <= m; a++) { tu[a] = ksm(a / (double)m, n); } double ss = 0; for (int a = 1; a <= m; a++) { ss += a*(tu[a] - tu[a - 1]); } printf("%.9f", ss);}
- CodeForces 453A
- codeforces 453A
- CodeForces 453A 概率题
- CodeForces-a
- Codeforces 903A A
- CodeForces 453A-周赛4补题
- CodeForces 453A(数学期望)
- Codeforces Round #453 (Div. 2) A-C
- Codeforces Round #453 (Div. 2) A,B
- Codeforces Round #453 (Div. 2) A
- CodeForces 18A A - Triangle
- CodeForces 133A A. HQ9+
- codeforces 651A A. Joysticks
- 【Codeforces 597A】A. Divisibility
- 【 Codeforces 615A】A. Bulbs
- A. Divisibility CodeForces 597A
- codeforces 417A A. Elimination
- CodeForces 534A A. Exam
- 07.Mybatis初级使用-resultMap(一)
- 华为交换机实现远程管理
- 欢迎使用CSDN-markdown编辑器
- 五 初始化与清理
- C#窗体程序Windows Media Player组件之播放功能
- codeforces 453A
- 一台电脑配置多台tomcat
- Mysql服务mysqld --install路径不对怎么整
- cmd如何执行cmake
- 第一章 开始启程,你的第一行Android代码
- 【LeetCode】538. Convert BST to Greater Tree
- spring之任务调度
- Adobe LiveCycle Designer ES4 表格绑定数据动态增加行
- flask学习笔记之python代码模式