hint

Posted by

ASK 27 Mar 2014 23:03

Use probability P(i,j) that a line with i rockets is finished after at most j salvos. The probability that it ends after exactly k+1 salvos is

P(i,k+1)-P(i,k) = 1/i sum_l P(l,k) * P(r,k) - P(l,k-1) * P(r,k-1),

where l is the index of the first launched rocket and thus the size of the left part and r is the size of the right part (r=i-1-l) of the line.

The output is with

cout << setprecision(12) << s*10 << endl;

*Edited by author 27.03.2014 23:04*