Cod sursa(job #2984550)
Utilizator | Deleanu Luca Deleanu_Luca | Data | 24 februarie 2023 14:12:31 |
---|---|---|---|
Problema | Dezastru | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.6 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream fin("dezastru.in");
ofstream fout("dezastru.out");
double P[27],TP[27][27];
int C[27][27];
int n,k;
int main()
{
fin>>n>>k;
for(int i=1; i<=n; i++)
fin>>P[i];
for(int i=0; i<=n; i++)
C[i][0]=TP[i][0]=1;
for(int i=1; i<=n; i++)
for(int j=1; j<=i; j++)
{
C[i][j]=C[i-1][j]+C[i-1][j-1];
TP[i][j]=TP[i-1][j]+TP[i-1][j-1]*P[i];
}
fout<<fixed<<setprecision(6)<<TP[n][k]/(double)C[n][k];
fin.close();
fout.close();
return 0;
}