Cod sursa(job #1680231)

Utilizator mihai.constantinConstantin Mihai mihai.constantin Data 8 aprilie 2016 16:31:03
Problema Dezastru Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <iostream>
#include <cstdio>
using namespace std;

const int N_max = 27;

double v[N_max];

int sol[N_max];

double SUM;
int NR;

int N, K;

void bkt(int p, int L, double P)
{
    if(p - 1 == K)
    {
        NR++;
        SUM += P;
    }
    else
        for(int i = 1 + L; i <= N - K + p; i++)
        {
            /* sol[p] = i; */

            bkt(p + 1, i, P * v[i]);
        }
}

int main()
{
    freopen("dezastru.in", "r", stdin);
    freopen("dezastru.out", "w", stdout);

    scanf("%d %d", &N, &K);
    for(int i = 1; i <= N; i++) scanf("%lf", &v[i]);

    bkt(1, 0, 1);

    printf("%.6lf", SUM / NR);

    return 0;
}