【Codeforces 453A】Little Pony and Expected Maximum

题目传送门: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;
}

又一次看到这个图了,蜜汁喜欢QAQ
o_690e2a0828381f3056038f33a8014c086e06f030

Leave a Reply

Your email address will not be published. Required fields are marked *