Cod sursa(job #1350620)
Utilizator | Data | 20 februarie 2015 21:05:07 | |
---|---|---|---|
Problema | Dezastru | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <fstream>
#include <cstdio>
using namespace std;
const int N = 1001;
double a[N][N], p[N];
int n, k;
ifstream in("dezastru.in");
int main(){
in >> n >> k;
for (int i = 1 ; i <= n ; i++)
in >> p[i];
for (int i = 0 ; i <= n ; i++)
a[i][0] = 1;
for (int i = 1 ; i <= n ; i++)
for (int j = 1 ; j <= i ; j++)
a[i][j] = (a[i - 1][j] * (i - j) + a[i - 1][j - 1] * p[i] * j) / i;
freopen("dezastru.out", "w", stdout);
printf("%.6lf\n", a[n][k]);
return 0;
}