DescriptionOSU is a popular leisure software. we can simplify and adapt the OSU rules to the following:there are n operations, each operation only success and failure, the success of the corresponding 1, the failure corresponds to the 0,n operation corresponds to 1 length of 01 strings of N. In this string continuous x 1 can contribute to the score of X^3, which x 1 can not be included in the other successive 1 (that is, a very long string of 1, as explained in the sample example)now give the N, and the success rate of each operation, please output the desired score, the output is rounded and retained 1 decimal places. Inputthe first line has a positive integer n, which indicates the number of operations. Next n rows each row has a real number between [0,1], indicating the success rate of each operation. OutputThere is only one real number that represents the answer. The answer is rounded and retains 1 decimal places. The desired DP, which maintains the length PX that expects the longest full 1 suffix before the current position, and the expected value of (PX) 2 px2. The contribution of each operation to the final answer is p* (3px2+3px+1), and P is the operational success rate.
#include <cstdio>intMain () {intN; Doublepx0), PX2 (0), P,ans (0); scanf ("%d",&N); while(n--) {scanf ("%LF",&p); Ans+=(3* (PX2+PX) +1)*p; PX2= (px2+2*px+1)*p; PX= (px+1)*p; } printf ("%.1f", ans); return 0;}
bzoj4318 osu!