The Probability Of Winning
All submissions for this problem are available.
T test cases follows. Each test case will consist of four space separeted integers T1, T2, T3 and T4, respectively.
For each test case, output a single line containing the probability that Artem will win. Your answer will be considered correct if it has an absolute error less then 10-6.
1 ≤ T ≤ 10000
1 ≤ T1, T2, T3 ≤ 1000000000
0 ≤ T4 < T1 + T2
Input 2 2 2 1 2 2 3 4 1 Output 0.5 0.4
In the first test case, the 5 possible outcomes after Chef discards 2 tickets is
- (0,2,1) with probability (1/10). Probability of winning is 0 - since there are no winning tickets!
- (2,0,1) with probability (1/10). Probability of winning is 1 - since there are no losing tickets!
- (2,1,0) with probability (1/5). Probability of winning is (2/3) - there are no second chances!
- (1,2,0) with probability (1/5). Probability of winning is (1/3) - there are no second chances!
- (1,1,1) with probability (2/5). Probability of winning is (1/3) + (1/3)*(1/2) = (1/2). This is calculated by considering the two cases
- The winning ticket is picked in the first turn - probability (1/3).
- A Type-3 ticket is picked in first turn, followed by the winning ticket - probability (1/3)*(1/2).
The over-all probability of winning is (1/10) + (2/15) + (1/15) + (1/5) = (1/2).
|Tags||ballon_ziq, july13, probability, simple, simple-math|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, 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, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.