Cod sursa(job #2501503)

Utilizator vali_27Bojici Valentin vali_27 Data 29 noiembrie 2019 20:02:18
Problema Dezastru Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.88 kb
#include <bits/stdc++.h>

using namespace std;

int s[26],n,m;
bool used[26];
float posibil[26],p,pn=1;


void afis(int k)
{
    for(int i=1;i<=k;++i)printf("%d ",s[i]);
    printf("\n");
}
void test(int k)
{
    float c=1;
    for(int i=1;i<=k;++i)
        c*=posibil[s[i]];

    p+=c/pn;
}
void bkt(int k)
{
    if(k == m+1)test(k-1);
    else
        for(int i=1;i<=n;++i)
    {
        if(used[i] == 1)continue;
        used[i]=1;
        s[k]=i;
        bkt(k+1);
        used[i]=0;
    }
}
void citire()
{
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;++i)
        scanf("%f",&posibil[i]);

    for(int i = n-m+1;i<=n;++i)
        pn*=i;
}
int main()
{
//    freopen("combinari.in","r",stdin);
//    freopen("combinari.out","w",stdout);
    citire();
    bkt(1);
    cout << setprecision(6) << fixed;
    printf("%f ",1.0/3);
    return 0;
}