10809: C_2
Description
Given three apples numbered from 1 to 3, you can choose two of them to eat at most. But as Fat Brother likes apple very much, thus he would choose two apples to eat. If both you and Fat Brother choose a same apple, you have to make a duel with him and the winner could get this apple. The probability of Fat Brother winning each duel is p. But as Fat Brother is every stubborn, he would never change his determined apples after first choose. The probability of Fat Brother choosing 1 and 2 is p1, choosing 1 and 3 is p2, choosing 2 and 3 is p3. So how do you choose apples you to make the expected number of the apple to be as much as possible? Note that maybe you have to take more than one duel with Fat Brother.
Input
The first line contains only one integer T, which is the number of test cases.
Each test case contains four decimal numbers p, p1, p2 and p3 as given above.
Output
For each test case, output the case number first, then output the expected number of the apple you could eat rounded to the fourth digit after decimal point. You should decide your choosing way to make this number to be as much as possible.
Sample Input Copy
2
0.5 0.5 0.5 0
0.5 0.3 0.3 0.4
Sample Output Copy
Case 1: 1.5000
Case 2: 1.3500
HINT
T<=100
0 <= p, p1, p2, p3 <=1
p1+p2+p3 = 1
Don’t use “float” to represent decimal number in language C or C++, please use “double” instead