#include <iostream>
#include <iomanip>
using namespace std;
double ans;
int n,x;
double a[20],b[20];
void rec(int r,int i,double prob){
if(r==0&&i==n){
ans+=prob;
return;
}
if(i==n)
return;
if(i==x)
return rec(r,i+1,prob);
rec(r-1,i+1,prob*a[i]);
rec(r,i+1,prob*b[i]);
}
int main(){
ios::sync_with_stdio(0);
int r,cs=1;
while(cin>>n>>r&&n){
cout<<"Case "<<cs++<<":"<<endl;
if(r==0){
for(int i=0;i<n;i++)
cout<<"0.000000"<<endl;
for(int i=0;i<n;i++){
cin>>ans;
}
continue;
}
for(int i=0;i<n;i++){
cin>>a[i];
b[i]=1-a[i];
}
ans=0,x=-1;
rec(r,0,1);
double pe=ans;
for(int i=0;i<n;i++){
ans=0,x=i;
rec(r-1,0,a[i]);
cout<<fixed<<setprecision(6)<<ans/pe<<endl;
}
}
}
#include <iomanip>
using namespace std;
double ans;
int n,x;
double a[20],b[20];
void rec(int r,int i,double prob){
if(r==0&&i==n){
ans+=prob;
return;
}
if(i==n)
return;
if(i==x)
return rec(r,i+1,prob);
rec(r-1,i+1,prob*a[i]);
rec(r,i+1,prob*b[i]);
}
int main(){
ios::sync_with_stdio(0);
int r,cs=1;
while(cin>>n>>r&&n){
cout<<"Case "<<cs++<<":"<<endl;
if(r==0){
for(int i=0;i<n;i++)
cout<<"0.000000"<<endl;
for(int i=0;i<n;i++){
cin>>ans;
}
continue;
}
for(int i=0;i<n;i++){
cin>>a[i];
b[i]=1-a[i];
}
ans=0,x=-1;
rec(r,0,1);
double pe=ans;
for(int i=0;i<n;i++){
ans=0,x=i;
rec(r-1,0,a[i]);
cout<<fixed<<setprecision(6)<<ans/pe<<endl;
}
}
}
Comments
Post a Comment