题目传送门:http://codeforces.com/problemset/problem/453/A
这个题目,为什么我又感觉很神QAQ
题解看这里:http://www.cnblogs.com/qscqesze/p/4411069.html
#include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cstdio> #include<cmath> #define LL long long #define abs(x) ((x)>0?(x):-(x)) using namespace std; int n,m; inline int read(){ char c=getchar(); int ret=0,f=1; while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();} while (c<='9'&&c>='0') ret=ret*10+c-'0',c=getchar(); return ret*f; } int main(){ m = read(); n = read(); double p = 1.0 - pow((double)(m-1)/m,n), vout = 0; for (int i=1;i<=m;i++) vout += (pow((double)i/m,n)-pow((double)(i-1)/m,n))*i; printf("%.10lf\n",vout); return 0; }