1, test instructions: A sequence, a continuous period of 1 pairs of points have < Span class= "Mi" id= "mathjax-span-1003" style= "font-family:mathjax_math-italic;" >x 3 Contribution, then ask the desired score
2, Analysis: A bare expectation DP, then new to add a 1, the contribution to the answer for x 3 ?(x?1 ) 3 =3 x 2 +3x+1 Direct violence calculates the desired square and expectation, and every time the DP is updated it's fine.
#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace STD;#define M 1000010inline intRead () {Charch = getchar ();intx =0, F =1; while(Ch <' 0 '|| CH >' 9 '){if(ch = ='-') F =-1; ch = getchar (); } while(' 0 '<= CH && Ch <=' 9 ') {x = x *Ten+ CH-' 0 '; ch = getchar (); }returnx * F;}DoubleL[M], l2[m], f[m];intMain () {intn = read (); for(inti =1; I <= N; i + +) {DoubleXscanf("%LF", &x); L[i] = (L[i-1] +1) * x; L2[i] = (L2[i-1] +2* L[i-1] +1) * x; F[i] = f[i-1] + (3* L2[i-1] +3* L[i-1] +1) * x; }printf("%.1lf\n", F[n]);return 0;}
bzoj4318--osu!