\(\large{题目链接}\)
\(\\\)
\(\Large\textbf{Solution: } \large{设取n次的得到的最大值为M,那么方案数为M^{n}-(M-1)^{n}。\\其中,M^n表示取值在\left[ 1.M\right]的方案数,M^{n - 1}表示取值在\left[ 1,M-1\right]的方案数。\\答案即为:\sum \limits^{m}_{i=1}i\cdot \dfrac {\left( i^{n}-(i-1)^{n}\right) }{m^{n}}=\sum \limits ^{m}_{i=1}\left( \dfrac {i}{m}\right) ^{n}-\left( \dfrac {i-1}{m}\right) ^{n}\times i。}\)
\(\\\)
\(\Large\textbf{Summary: } \large{在实数域算幂直接用pow库函数即可,愚蠢的我一度想打快速幂。}\)
\(\\\)
\(\Large\textbf{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\n", ans);
return 0;
}