Cod sursa(job #2355174)

Utilizator Moise_AndreiMoise Andrei Moise_Andrei Data 25 februarie 2019 21:19:51
Problema Dezastru Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <bits/stdc++.h>
using namespace std;
ifstream in("dezastru.in");
ofstream out("dezastru.out");
double v[50][50];
int main()
{
    int n, k;
    in >> n >> k;
    v[0][0] = 1;
    for(int i = 1; i <= n; i ++)
    {
        double a;
        in >> a;
        for(int j = 1; j <= i; j ++)
        {
            v[i][0] = 1;
            v[i][j] = v[i - 1][j] + (double)(a * v[i - 1][j - 1]);
        }
    }
    double rez = v[n][k];
    for(int i = k + 1; i <= n; i ++)
        rez /= i;
    for(int i = 1; i <= n - k; i ++)
        rez *= i;
    out << rez;
    return 0;
}