Cod sursa(job #2567306)

Utilizator Teo_1101Mititelu Teodor Teo_1101 Data 3 martie 2020 16:33:03
Problema Dezastru Scor 60
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.86 kb
#include <bits/stdc++.h>

using namespace std;

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

int N, K;
long double a[30];

vector < long double > P;
long double x;
int mex;

void Back( int k )
{
    for( int i = mex+1; i <= N; ++i )
    {
        //cout << a[i]<< ' ';
        int c = mex;
        x = x*a[i];
        mex = i;
        if( k == K )
            P.push_back( x );
        else Back( k+1 );
        mex = c;
        x = x/a[i];
    }
}
void Solve()
{
    fin >> N >> K;
    for( int i = 1; i <= N; ++i )
        fin >> a[i];

    x = 1;
    Back( 1 );

    x = 0;
    for( int i = 0; i < P.size(); ++i )
        x = x+P[i];

    //fout << fixed << setprecision( 6 ) << x << '\n';
    x = x/ double(P.size());

    fout << fixed << setprecision( 6 ) << x;
}
int main()
{
    Solve();
    return 0;
}