Cod sursa(job #2282788)
Utilizator | Data | 14 noiembrie 2018 15:33:20 | |
---|---|---|---|
Problema | Dezastru | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
int n,k;
ld dp[30];
ld sum=0;
int main()
{
freopen("dezastru.in","r",stdin);
freopen("dezastru.out","w",stdout);
cin>>n>>k;
for(int i=1;i<=n;i++)
{
ld x;
cin>>x;
for(int cnt=min(i,k);cnt>=1;cnt--)
{
dp[cnt]=(dp[cnt-1]*x+dp[cnt]+(cnt==1)*x);
}
}
ld ans=dp[k];
for(ld i=1;i<=n;i++) ans/=i;
for(ld i=1;i<=n-k;i++) ans*=i;
for(ld i=1;i<=k;i++) ans*=i;
cout<<fixed<<setprecision(7)<<ans<<"\n";
return 0;
}