标签:can ble scan span color code bzoj ace str
注意dp1,dp2维护的是后缀的期望得分,而dp3维护的是全部的期望得分。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define maxn 100500 using namespace std; int n; double dp1[maxn],dp2[maxn],dp3[maxn],x; int main() { scanf("%d",&n); for (int i=1;i<=n;i++) { scanf("%lf",&x); dp1[i]=(dp1[i-1]+1)*x; dp2[i]=(dp2[i-1]+2*dp1[i-1]+1)*x; dp3[i]=dp3[i-1]+(3*dp2[i-1]+3*dp1[i-1]+1)*x; } printf("%.1lf\n",dp3[n]); return 0; }
标签:can ble scan span color code bzoj ace str
原文地址:http://www.cnblogs.com/ziliuziliu/p/6040111.html