Cod sursa(job #1721357)
| Utilizator | Data | 25 iunie 2016 13:51:15 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.63 kb |
#include <fstream>
#include <iomanip>
using namespace std;
float dp[30][30],comb[30][30];
int main()
{
ifstream fin("dezastru.in");
ofstream fout("dezastru.out");
int n,k;
fin>>n>>k;
float p;
dp[0][0]=1;
for(int i=1;i<=n;i++) {
fin>>p;
dp[i][0]=1;
for(int j=1;j<=i;j++)
dp[i][j]=dp[i-1][j]+dp[i-1][j-1]*p;
}
comb[0][0]=1;
for(int i=1;i<=n;i++) {
comb[i][0]=1;
for(int j=1;j<=k;j++) {
comb[i][j]=comb[i-1][j]+comb[i-1][j-1];
}
}
fout<<setprecision(6)<<fixed<<dp[n][k]/comb[n][k];
return 0;
}
