首页 > 代码库 > Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum

Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum

题目链接

题意:

分析:

 1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cmath> 5 #include <cstdio> 6 #include <vector> 7 #include <algorithm> 8 #define LL long long 9 using namespace std;10 11 int main()12 {13     int i;14     double ans, n, m, temp, pre;15     while(cin>>m>>n)16     {17         ans = pow(1.0/m, n);18         pre = ans;19         for(i = 2; i <= m; i++)20         {21             temp = pow(i/m, n);22             ans += (temp-pre)*i;23             pre = temp;24         }25 26         printf("%.4lf\n", ans);27     }28     return 0;29 }