Cod sursa(job #1811672)

Utilizator raulmuresanRaul Muresan raulmuresan Data 21 noiembrie 2016 14:52:11
Problema Dezastru Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.22 kb
#include<fstream>
#include<vector>
#include<string>
#include<iomanip>
#define modulo 666013

using namespace std;

ifstream fin("dezastru.in");
ofstream fout("dezastru.out");


string sir;
int i, n, k, j,contor,st,dr,sol,x,y;
double a[100];
double d[100][100]; //d[i][j] = suma prob. de a alege j prob. dintre primele i
int comb[100][100];

int main()
{
    fin >> n >> k;
    for(i = 1; i <= n; i++)
    {
        fin >> a[i];
    }


    d[0][0] = 1;
    for(i = 1; i<= n; i++)
    {
        d[i][0] = 1;
        for(j = 1; j <= i; j++)
        {
            d[i][j] = d[i - 1][j] + (d[i - 1][j - 1] * a[i]);
        }

    }

    for(i = 1; i <= n; i++)
    {
        //fout << a[i] << " ";
    }

    comb[0][0] = 1;
    comb[1][1] = 1;comb[1][2] = 1;
    for(i = 2; i <= 25; i++)
     {
        // comb[]
         for(j = 1; j <= 25;j++)
         {
             comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
         }
     }


     for(i = 1; i <= n; i++)
     {
         for(j = 1; j <= n;j++)
         {
             //fout << d[i][j] <<" ";
         }
         //fout<<"\n";
     }
    double sol = d[n][k]/comb[n][k + 1];
     fout<< setprecision(6) << sol <<"\n";

}