题意:n个人去购物,要求只有k个人买东西。给你n个人每个人买东西的概率,然后要你求出这n个人中有k个人购物并且其中一个人是ni的概率pi。
分析:设B是n个人中选择k个人。设Ai是除了第i个人外选择k - 1个人。那么P = P(Ai)∗ pi / P(B);所以用dfs求出B,和Ai的概率,然后代入公式得到最后的结果。
代码如下:

//
//Created by BLUEBUFF 2016/1/11
//Copyright (c) 2016 BLUEBUFF.All Rights Reserved
//

#pragma comment(linker,"/STACK:102400000,102400000")
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/hash_policy.hpp>
//#include <bits/stdc++.h>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <time.h>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <sstream> //isstringstream
#include <iostream>
#include <algorithm>
using namespace std;
//using namespace __gnu_pbds;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, LL> pp;
#define REP1(i, a, b) for(int i = a; i < b; i++)
#define REP2(i, a, b) for(int i = a; i <= b; i++)
#define REP3(i, a, b) for(int i = a; i >= b; i--)
#define CLR(a, b) memset(a, b, sizeof(a))
#define MP(x, y) make_pair(x,y)
template <class T1, class T2>inline void getmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void getmin(T1 &a, T2 b) { if (b<a)a = b; }
const int maxn = 100010;
const int maxm = 1e5+5;
const int maxs = 10;
const int maxp = 1e3 + 10;
const int INF  = 1e9;
const int UNF  = -1e9;
const int mod  = 1e9 + 7;
const int rev = (mod + 1) >> 1; // FWT
const double PI = acos(-1);
//head

int n, r;
bool vis[25];
double p[25], ans[25];

void dfs(int k, int cnt){
    if(cnt == r){
        double res = 1.00;
        REP2(i, 1, n){
            if(vis[i]) res = res * p[i];
            else res = res * (1 - p[i]);
        }
        ans[0] += res;
        REP2(i, 1, n){
            if(vis[i]) ans[i] += res;
        }
        return ;
    }
    else{
        REP2(i, k + 1, n){
            vis[i] = 1;
            dfs(i, cnt + 1);
            vis[i] = 0;
        }
    }
}

int main()
{
    int ks = 0;
    while(scanf("%d%d", &n, &r) != EOF)
    {
        if(n == 0 && r == 0) break;
        CLR(vis, 0);
        CLR(ans, 0);
        REP2(i, 1, n) scanf("%lf", &p[i]);
        dfs(0, 0);
        printf("Case %d:\n", ++ks);
        REP2(i, 1, n){
            printf("%.6f\n", ans[i] / ans[0]);
        }
    }
    return 0;
}