Target Practice

All submissions for this problem are available.
Chef has recently taken up marksmanship, but he's not very good at it.
Chef has set up a number of targets in a line.
When Chef shoots at a target, he may hit the target, but he may instead hit
the target to the left, or the target to the right
(or if there is no such target, miss completely).
Chef knows the probability of his shot going straight, left, or right,
and wants to hit each target at least once using as few shots as possible.
Help Chef determine the expected number of shots required, provided an optimal strategy is followed.
Note that Chef may only shoot at targets, but may shoot at a target that's already been hit.
Input
Input will begin with an integer T, the number of test cases.
Each test case will consist of 4 integers:
N, the number of targets,
L, the probability of the shot veering to the left,
S, the probability of the shot going straight,
and R, the probability of the shot veering to the right.
L, S, and R are given as percents.
Output
For each test case, output the expected number of shots to hit all targets, rounded to 6 decimal places.
Sample Input
4 3 25 50 25 3 10 10 80 5 25 50 25 8 30 35 35
Sample Output
4.666667 10.361111 7.541667 13.107725
In the first example, Chef shoots at the center target until any 2 targets have been hit,
then he shoots at the remaining target.
Constraints
 T≤30
 1≤N≤18
 0<L,S,R
 L+S+R=100
Author:  pieguy 
Tester:  chmel_tolstiy 
Editorial  http://discuss.codechef.com/problems/TARPRACT 
Tags  cook14, medium, pieguy 
Date Added:  7092011 
Time Limit:  0.56 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 