Facebook Interview Question for Software Engineer / Developers
- 0of 0 votes
You are given C containers, B black balls and an unlimited number of white balls. You want to distribute balls between the containers in a way that every container contains at least one ball and the probability of selecting a white ball is greater or equal to P percent. The selection is done by randomly picking a container followed by randomly picking a ball from it.- unknown February 16, 2012 in United States
Find the minimal required number of white balls to achieve that.
The first line contains 1 <= T <= 10 - the number of testcases.
Each of the following T lines contain three integers C B P separated by a single space 1<= C <= 1000; 0 <= B <= 1000; 0 <= P <= 100;
For each testcase output a line containing an integer - the minimal number of white balls required. (The tests will assure that it's possible with a finite number of balls)
1 1 60
2 1 60
10 2 50
In the 1st testcase if we put 2 white balls and 1 black ball in the box the probability of selecting a white one is 66.(6)% which is greater than 60%
In the 2nd testcase putting a single white ball in one box and white+black in the other gives us 0.5 * 100% + 0.5 * 50% = 75%
For the 3rd testcase remember that we want at least one ball in each of the boxes.
| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm Probability
Interview Type: Written Test