(large{题目链接})
(\)
(Large extbf{Solution: } large{设取n次的得到的最大值为M,那么方案数为M^{n}-(M-1)^{n}。\其中,M^n表示取值在left[ 1.M
ight]的方案数,(M-1)^{n}表示取值在left[ 1,M-1
ight]的方案数。\答案即为:sum limits^{m}_{i=1}icdot dfrac {left( i^{n}-(i-1)^{n}
ight) }{m^{n}}=sum limits ^{m}_{i=1}left( dfrac {i}{m}
ight) ^{n}-left( dfrac {i-1}{m}
ight) ^{n} imes i。})
(\)
(Large extbf{Summary: } large{在实数域算幂直接用pow库函数即可,愚蠢的我一度想打快速幂。})
(\)
(Large extbf{Code: })
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> m >> n;
if (m == 1) return cout << "1.0", 0;
double ans = 0;
for (int i = 1; i <= m; ++i) ans += 1.0 * i * (pow(1.0 * i / m, n) - pow(1.0 * (i - 1) / m, n));
printf("%.12lf
", ans);
return 0;
}