其他分享
首页 > 其他分享> > Codeforces - Little Pony and Expected Maximum

Codeforces - Little Pony and Expected Maximum

作者:互联网

题目链接:Codeforces - Little Pony and Expected Maximum


假设最大值为 k ,那么期望是多少呢? k * (k ^ n - (k-1) ^ n) / m ^ n

就是可能是方案数 / 总方案数 * k


AC代码:

#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
int m,n;	double res;
signed main(){
	cin>>m>>n;
	for(double i=1;i<=m;i++)	res+=i*(pow(i/m,n)-pow((i-1)/m,n));
	printf("%.10lf\n",res);
	return 0;
}

标签:Little,Pony,int,Codeforces,long,Maximum,Expected
来源: https://blog.csdn.net/weixin_43826249/article/details/104850642