Wow! this is a really good solution! He has just played around with the formula and calculated Ai / A1 on the fly without actually calculating the whole Ai first. Ai is the product of numbers in the ith row (probability that ith guy wins). The answer initially is A1 / (A1 + A2 + … + An). Divide both sides by A1 and you get 1 / (1 + A2/A1 + A3/A1 + … + An/A1). nice!
oh. nice soln. he nailed it
Yeah, @rushilpaul explained it very correctly. Thanks
The variable ‘waah’ takes care of when the probability is zero
+1 for the variable names.
@amaneureka: Sorry, I didn’t mean to not let you sleep because of my comment.
If you have time, could you swap the 3rd and the 4th ‘for’ loop? The idea of my test case was that (0.0001/0.9999)^5000 would be 0 because of the precision and that multiplying back by (0.9999/0.0001)^5000 cannot change that. (For example http://paste.ideaslabs.com/show/CvvvJDHinq returns 0 and 0 in Java).