Submit | All submissions | Best solutions | Back to list |
SCPC11G - Indomie |
During recession, Amjad needs to queue for SembakoPlus. Sembako, as we all know, stands for “Sembilan Bahan Pokok” which consists of 9 kinds of item: Rice, Sugar, Cooking-oil, Meat, Egg, Milk, Corn, Kerosene and Iodized Salt. SembakoPlus consists of Sembako and one more item: Indomie! Amjad’s favorite of all time!! (therefore, no wonder why he could stand for this long queue).
Each person in the queue is allowed to pick only one item. No need to ask, Amjad wants only Indomie. Unfortunately, they are running out of SembakoPlus stock and currently there are three kinds of item left: Rice, Sugar and Indomie. As he could see from afar, he is quite sure that Rice and Sugar will be enough for everybody.
Given the number of remaining Indomie and the number of people queuing in front of Amjad, your task is to count the probability that he will get his Indomie. Amjad can’t do programming right now as he is very nervous so he can’t think logically. He needs your help!
Input
There will be multiple test cases for this problem. Each test case contains two integers N (1 ≤ N ≤ 50) and S (0 ≤ S ≤ 50), where N is the number of people queuing in front of Amjad and S is the remaining number of Indomie.
For each case, print in a single line the probability in percentage that he will get his Indomie with 5 digits precision (he’s being paranoid)
Example
Input: 2 1 3 2 4 0 4 1 10 10 14 9 30 14 Output: 50.00000 76.92308 0.00000 33.33333 99.99831 98.65515 95.16071
Added by: | Ali Arous |
Date: | 2011-10-19 |
Time limit: | 0.903s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Syrian Collegiate Programming Contest 2011 |
hide comments
|
|||||
2017-05-07 13:42:05
Yeah, the probabilities of each sequence don't follow a probability tree. You are just supposed to count (number of possible sequences where at least 1 Indomie is not eaten)/(number of all possible sequences) Last edit: 2017-05-07 13:42:48 |
|||||
2014-07-14 17:17:34 zicowa
A simple optimisation will definately work :P :D O((n-k)*k) passed AC |
|||||
2012-08-20 01:31:05 Hussain Kara Fallah
You should use BIG INT .... Be careful ! |
|||||
2012-07-11 09:44:20 Bharath Reddy
@fitcat and Tywan: You can't have the combination Indomie, Indomie for the first test case. So the probability is only 0.5 |
|||||
2012-03-26 08:50:33 berney
my code runs fine in ideone(in java6)... but here it is giving compilation error... can anyone please tell what is wrong? solution id 6726890... |
|||||
2011-12-28 08:45:03 Devil D
what is the answer for 20 19 ? 100.00000? I am getting correct result for the given test cases. but WA here. my submission is '6255319' Last edit: 2011-12-28 08:48:36 |
|||||
2011-11-26 09:27:47 fitcat
The example output is incorrect. For the 1st sample test case, the correct answer should be 2/3*2/3 = 4/9 = 44.44444 as Tywan pointed it out. |
|||||
2011-10-27 08:13:58 Tywan
I've solved the problem but still believe the right answer should be 44.44444 74.07407 and so on... |
|||||
2011-10-24 01:46:27 Lukmanul Hakim
What? Indomie from Syria? :O |
|||||
2011-10-21 13:59:07 Ayan Ghatak
how long do i scan??till eof?? |