×

# how to solve BUCKETS of december lunchtime 2018 question ?

 0 Can someone tell me how to solve Choosing from Buckets problem ? asked 30 Dec '18, 00:35 3●2 accept rate: 0%

 2 Chosing a ball from bucket have two outcomes - ball has color i ball does not have color i For first bucket - Probability that ball has ith color = (No of balls with ith color) / Total balls for consecutive bucket k - Case1 - The ball added to bucket k had color i Probability that new ball taken out of bucket k has ith color = Probability that ball with ith color came out of previous bucket * (1 + count of balls with color i in kth bucket)/ (1 + Total balls in bucket k) Case2 - The ball added to bucket k did not had color i Probability that new ball taken out of bucket k has ith color = (1 - Probability that ball with ith color came out of previous bucket) * (count of balls with color i in kth bucket)/ (1 + Total balls in bucket k) Total probability = Case1 + case 2 Calculate this for each color for each bucket. answered 30 Dec '18, 00:47 4★masterox 182●4 accept rate: 0%
 0 Calculate probability for each color(1 to k) by looping from 1 to n and using simple formula prob[i]=(prob[i-1](colorcnt+1))/(totalcnt+1) + ((1-prob[i-1])(colorcnt))/(totalcnt+1). Reason : with probability[i-1] we will get this color from previous lot, and color count in this lot will increase by 1 and with 1-probability[i-1] we will get different color from previous lot and color count in this lot will remain the same whereas total count will increase by 1 in both cases. (For the start prob[1] is simply colorcnt_in_1/total_cnt_of_1 ) For better reference of the above text see this solution : https://www.codechef.com/viewsolution/22121098 answered 30 Dec '18, 00:55 4★lets_see 1 accept rate: 0%
 0 see my solution. written in most easy way to understand. solve(x,y) is probability for xth ball color to come out in yth bucket. #include #include using namespace __gnu_pbds; #define ll long long int #define li long int using namespace std; typedef vector vi; typedef pair pi; typedef tree, rb_tree_tag, tree_order_statistics_node_update> indexed_set; #define EB emplace_back #define REP(i, x, y) for(long long int i=x ; i>n>>k; cout<>a[i][j]; sum[i]+=a[i][j]; } } REP(i,0,k) { cout<< solve(i+1,n) <<" "; } return 0; }  answered 30 Dec '18, 13:12 118●6 accept rate: 7%
 0 Can Anyone point out the mistake with this solution. https://www.codechef.com/viewsolution/22135717 answered 30 Dec '18, 16:15 1 accept rate: 0%
 0 My solution-- https://www.codechef.com/viewsolution/22135834 answered 30 Dec '18, 16:39 21●4 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×553

question asked: 30 Dec '18, 00:35

question was seen: 506 times

last updated: 31 Dec '18, 23:16