Target PracticeProblem code: TARPRACT |
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 |
| Date Added: | 7-09-2011 |
| Time Limit: | 6 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions
