DAB - DAB Loves Sweets
Dab is a petty thief with a sweet tooth. One fine day Dab was caught stealing traditional Indian sweets from Pattanaik sweet corner. Being a lazy lad, Dab was immediately caught and forced to reveal what sweet he had. Now there are n boxes numbered 1 to n each containing three type of sweets i.e Gulab Jamun, Rasgulla and ladoo.
Given that Dab had stuffed his mouth with a sweet "X" find the probability that he stole from the kth box.
Input
First line contains T the number of test cases.
Each test case contains the value of n(the number of boxes). The following n lines contains three integers each. Each of which denote the number of ladoos, Gulab Jamun and Rasgulla in each box respectively.
The (n+1) th line of each test case contains the value of k followed by character 'L' or 'G' or 'R' where 'L' denotes a ladoo, 'G' denotes a gulab jamun, 'R' denotes a Rasgulla.
Output
For each test case output the probability that dab stole from the kth box. Print the value rounded off to 9 decimal places.
Example
Input: 1 3 5 5 5 3 4 5 2 4 5 2 L Output: 0.326732673
Constraints:
1<=t<=20
1<=n<200
1<=k<=n
1<= number of each type of sweet <200
hide comments
Francky:
2013-03-17 08:55:51
(ter) The input is still badly formated. It's a problem for python users. I would like to see this fixed. Please. It will be un-hidden when fixed. |
|
mystique_blue:
2013-03-17 08:36:57
@Rohit use double. :).
|
|
Amit Jain:
2013-03-15 05:09:13
dont know what is going on here..%1.9lf was giving wrong answer and %.9lf is accepted |
|
Francky:
2013-03-14 19:31:00
(bis) The input is still badly formated. It's a problem for python users. I would like to see this fixed. Should I hide the problem until this ? I hope not. |
|
rohit ajmera:
2013-03-14 17:40:41
don't know why the last 3 digits are wrong
|
|
Ouditchya Sinha:
2013-03-14 09:12:10
Nice but easy problem... :) |
|
Francky:
2013-03-12 13:17:10
There is a problem with input formating, reading it with python shows that, please fix the input file as in the description. Thanks for that.
|
|
Vipul Pandey:
2013-03-11 16:12:18
Just basic probability! |
|
Kevin Sebastian:
2013-03-11 10:42:19
range of n?
|
Added by: | Rishikesh Jha |
Date: | 2013-03-11 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own |