BZOJ4318——OSU!
2024-08-26 20:10:03
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;
}
最新文章
- jQuery基础知识准备
- Linux_用户级_常用命令(3):mkdir
- js中各种跨域问题实战小结(一)
- ubuntu:solve the problem of &#39;E:Problem with MergeList /var/lib/apt/lists/&#39;
- DataGridView 行、列的隐藏和删除
- 利用Boost影响Lucene查询结果的排序
- WinForm C#全局错误捕捉处理【整理】
- IE-一根网线二台电脑上网
- NSURLSession -- 备忘
- C# WinForm中实现CheckBox全选反选功能
- BestCoder Round #75 King&;#39;s Cake 模拟&;amp;&;amp;优化 || gcd
- 【绘图技巧】ps快捷键的用法
- Extensions in UWP Community Toolkit - Mouse Cursor
- 关于executemany()方法在不同OS和DB API下的不同表现的测试
- SQL Server 2016 附加数据库提示创建文件失败如何解决
- Zabbix告警脚本-短信
- vue-cli脚手架之build文件夹上半部
- SAP UI 搜索分页技术
- CF949D Curfew
- Nginx+Tomcat集群配置
热门文章
- [LeetCode] Factorial Trailing Zeroes 求阶乘末尾零的个数
- FineUI(专业版)公测版发布(这速度,真TM快!)
- [EF2]Sneak Preview: Persistence Ignorance and POCO in Entity Framework 4.0
- c++局域网多播
- C/C++ 标准输入输出重定向
- arcgis出图步骤(缩减版)
- [转]ExtJs基础--Html DOM、Ext Element及Component三者之间的区别
- Android源码——Broadcast Receiver
- 每天一个 Linux 命令(21):find命令之xargs
- oracle--第一天PLSQL--bai