ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1776. Anniversary Firework

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