QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#357984#5105. Hand of the Free MarkedDoqeWA 0ms3836kbC++20864b2024-03-19 16:07:512024-03-19 16:07:51

Judging History

你现在查看的是最新测评结果

  • [2024-03-19 16:07:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3836kb
  • [2024-03-19 16:07:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
long double fac(long double m)
{
	long double ans=1;
	for(int i=1;i<=m;++i)ans=ans*i;
	return ans;
}
long double C(long double n,long double m)
{
	long double ans=1;
	for(int i=n-m+1;i<=n;++i)ans=ans*i;
	return ans/fac(m);
}
double ans=0;
int k,m,a[100],z[102];
void dfs(int x,int s)
{
	if(x==m+1)
	{
		if(s)return;
		long double p=0,q=1;
		for(int i=1;i<=m;++i)if(z[i])
			p+=C(a[i],z[i]-1)/C(a[i],z[i]),q*=C(a[i],z[i]);
//		cerr<<": ";for(int i=1;i<=m;++i)cerr<<z[i]<<",";cerr<<" : "<<p<<" "<<q<<" "<<1/q<<endl;
		ans+=min(p*fac(k-1),1.0L)*q;return;
	}
	for(int i=0;i<=s;++i)
	{
		z[x]=i;dfs(x+1,s-i);
	}
}
int main()
{
	cin>>k>>m;long double n=0;
	for(int i=1;i<=m;++i)cin>>a[i],n+=a[i];
	dfs(1,k);
//	cerr<<ans<<" "<<C(n,k)<<endl;
	printf("%.12Lf\n",ans/C(n,k));
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3836kb

input:

3 3 2 1 2

output:

-nan

result:

wrong output format Expected double, but "-nan" found