eolymp
bolt
Try our new interface for solving problems
Problems

Probability Given

Probability Given

\textbf{n} friends go to the local super market together. The probability of their buying something from the market is \textbf{p_1}, \textbf{p_2}, \textbf{p_3}, \textbf{...}, \textbf{p_n} respectively. After their marketing is finished you are given the information that exactly \textbf{r} of them has bought something and others have bought nothing. Given this information you will have to find their individual buying probability. \InputFile The input file contains at most \textbf{50} sets of inputs. The description of each set is given below: First line of each set contains two integers \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{20}) and \textbf{r} (\textbf{0} ≤ \textbf{r} ≤ \textbf{n}). Meaning of \textbf{n} and \textbf{r} are given in the problem statement. Each of the next \textbf{n} lines contains one floating-point number \textbf{p_i} (\textbf{0.1} ≤ \textbf{p_i} ≤ \textbf{1}) which actually denotes the buying probability of the \textbf{i}-th friend. All probability values should have at most two digits after the decimal point. Input is terminated by a case where the value of \textbf{n} and \textbf{r} is zero. This case should not be processes. \OutputFile For each line of input produce \textbf{n + 1} lines of output. First line contains the serial of output. Each of the next \textbf{n} lines contains a floating-point number which denotes the buying probability of the \textbf{i}-th friend given that exactly \textbf{r} has bought something. These values should have six digits after the decimal point. Follow the exact format shown in output for sample input.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3 2
0.10
0.20
0.30
5 1
0.10
0.10
0.10
0.10
0.10
0 0
Output example #1
Case 1:
0.413043
0.739130
0.847826
Case 2:
0.200000
0.200000
0.200000
0.200000
0.200000