Codeforces Round #259 (Div. 1) A. Little Pony and Expected Maximum 数学公式结论找规律水题
2015-04-09 19:17
676 查看
A. Little Pony and Expected Maximum
Time Limit: 1 Sec Memory Limit: 256 MB题目连接
http://codeforces.com/contest/453/problem/ADescription
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.Sample Input
6 1Sample Output
3.500000000000HINT
[b]题意[/b]给你一个m面的筛子,然后扔N次,求最大值的期望是多少
[b]题解:[/b]
一开始还以为是个概率dp,哎
原来是一道数学题
我们这样想,相当于求一个长度为n的序列,然后问序列中最大值的期望是多少
对于最大值为k的序列,总共有k^n-(k-1)^n这么多个
然后我们递推搞一搞就好啦
[b]代码:[/b]
//qscqesze #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> #include <map> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define maxn 200001 #define mod 10007 #define eps 1e-9 //const int inf=0x7fffffff; //无限大 const int inf=0x3f3f3f3f; /* inline ll read() { int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int buf[10]; inline void write(int i) { int p = 0;if(i == 0) p++; else while(i) {buf[p++] = i % 10;i /= 10;} for(int j = p-1; j >=0; j--) putchar('0' + buf[j]); printf("\n"); } */ //************************************************************************************** int main() { int m,n; cin>>m>>n; double pre=0; double ans=0; for(int i=1;i<=m;i++) { double now=pow((double(i)/double(m)),double(n)); //cout<<now<<endl; ans+=(now-pre)*i; pre=now; } printf("%.10f\n",ans); }
相关文章推荐
- Codeforces Round #259 (Div. 2) C Little Pony and Expected Maximum
- Codeforces Round #259 (Div. 2) C. Little Pony and Expected Maximum
- codeforces #259 DIV2 C题 Little Pony and Expected Maximum(容斥+快速幂+公式推导)
- Codeforces Round #259 (Div. 2) E. Little Pony and Summer Sun Celebration
- Codeforces Round #259 (Div. 2) B - Little Pony and Sort by Shift
- Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shift(序列)
- Codeforces Round #259 (Div. 2) A.Little Pony and Crystal Mine
- Codeforces Round #259 (Div. 2)-D. Little Pony and Harmony Chest
- Little Pony and Expected Maximum CodeForces - 453A (数学期望)
- Codeforces Round #259 (Div. 2) A-Little Pony and Crystal Mine
- Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shift
- 【Codeforces Round 169 (Div 2) D】【简单数位贪心】Little Girl and Maximum XOR 区间选两数使得异或值尽可能大
- Codeforces Round #259 (Div. 2)C. Little Pony and Expected Maximum(数学期望)
- Codeforces Div. 2 #259-A. Little Pony and Crystal Mine
- Codeforces Div. 2 #259-C. Little Pony and Expected Maximum
- Codeforces Round #169 (Div. 2) D. Little Girl and Maximum XOR(贪心,中等)
- Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum (数学期望)
- 【Codeforces Round 332 (Div 2)D】【数学 公式推导】Spongebob and Squares 正方形数量恰好为x个的所有大矩形
- codeforces C. Little Pony and Expected Maximum
- Codeforces Round #129 (Div. 2) B. Little Elephant and Sorting