1、题意:一个序列,连续的一段1对得分具有贡献,那么问期望得分

2、分析:一道裸的期望dp,那么新加入一个1,对答案的贡献为 直接暴力算出期望的平方和期望,每次dp的时候更新一下就好了

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
#define M 1000010

inline int read(){
    char ch = getchar(); int x = 0, f = 1;
    while(ch < '0' || ch > '9'){
        if(ch == '-') f = -1;
        ch = getchar();
    }
    while('0' <= ch && ch <= '9'){
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

double l[M], l2[M], f[M];

int main(){
    int n = read();
    for(int i = 1; i <= n; i ++){
        double x; scanf("%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;
}

最新文章

  1. jQuery基础知识准备
  2. Linux_用户级_常用命令(3):mkdir
  3. js中各种跨域问题实战小结(一)
  4. ubuntu:solve the problem of &#39;E:Problem with MergeList /var/lib/apt/lists/&#39;
  5. DataGridView 行、列的隐藏和删除
  6. 利用Boost影响Lucene查询结果的排序
  7. WinForm C#全局错误捕捉处理【整理】
  8. IE-一根网线二台电脑上网
  9. NSURLSession -- 备忘
  10. C# WinForm中实现CheckBox全选反选功能
  11. BestCoder Round #75 King&amp;#39;s Cake 模拟&amp;amp;&amp;amp;优化 || gcd
  12. 【绘图技巧】ps快捷键的用法
  13. Extensions in UWP Community Toolkit - Mouse Cursor
  14. 关于executemany()方法在不同OS和DB API下的不同表现的测试
  15. SQL Server 2016 附加数据库提示创建文件失败如何解决
  16. Zabbix告警脚本-短信
  17. vue-cli脚手架之build文件夹上半部
  18. SAP UI 搜索分页技术
  19. CF949D Curfew
  20. Nginx+Tomcat集群配置

热门文章

  1. [LeetCode] Factorial Trailing Zeroes 求阶乘末尾零的个数
  2. FineUI(专业版)公测版发布(这速度,真TM快!)
  3. [EF2]Sneak Preview: Persistence Ignorance and POCO in Entity Framework 4.0
  4. c++局域网多播
  5. C/C++ 标准输入输出重定向
  6. arcgis出图步骤(缩减版)
  7. [转]ExtJs基础--Html DOM、Ext Element及Component三者之间的区别
  8. Android源码——Broadcast Receiver
  9. 每天一个 Linux 命令(21):find命令之xargs
  10. oracle--第一天PLSQL--bai