什么什么期望的,不会!
(题解http://blog.sina.com.cn/s/blog_140e100580102wj4e.html(看不懂))
#include<bits/stdc++.h>
#define LL long long
#define LD long double
#define N 100005
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
LD C[];
LD dp[][][];
int a[];
int main()
{
int n=ra();
C[]=;
for (int i=; i<=n; i++)
{
C[i]=C[i-]*(LD)i;
a[i]=ra();
}
sort(a+,a+n+);
int m=ra();
dp[][][]=; dp[][][a[]]=;
for (int i=; i<=n; i++)
for (int j=; j<=i; j++)
for (int k=; k<=m; k++)
{
dp[i+][j+][k+a[i+]]+=dp[i][j][k];
dp[i+][j][k]+=dp[i][j][k];
}
LD res=;
for (int j=; j<=n; j++)
for (int k=; k<=m; k++)
{
res+=dp[n][j][k]*(C[j]*C[n-j]);
cout<<j<<" "<<k<<" "<<dp[n][j][k]<<endl;
}
res=res/C[n];
cout<<res;
return ;
}