Luogu P1654 OSU!
2024-08-21 14:34:51
写法和CF235B Let's Play Osu!非常相似。但是这个题厉害就厉害在统计的贡献里面有一个平方的期望,而这个平方的期望和期望的平方是完全不一样的,需要另外统计,逻辑上仔细想一想就会明白。
期望\(dp\)没那么可怕,但是确实非常不容易调试。所以一定要在第一次推出式子的时候,保证式子的正确。哪怕先写一个暴力,也比写出锅过不了样例根本没法调的正解要好。
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n; double p[N], E1[N], E2[N], ans;
int main () {
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> p[i];
E1[i] = p[i] * (E1[i - 1] + 1);
E2[i] = p[i] * (E2[i - 1] + 2 * E1[i - 1] + 1);
ans += p[i] * (3 * E2[i - 1] + 3 * E1[i - 1] + 1);
}
printf ("%.1lf\n", ans);
}
最新文章
- iOS开发的知名大牛博客小汇
- hibernate联合主键 注解方式
- Android 开发必备知识:我和 Gradle 有个约会
- Android的学习——ubuntu下android5.1源码的make编译
- 谈谈eclipse使用技巧二
- 设计模式->;观察者模式
- 禁止苹果浏览器Safari将数字识别成电话号码的方法
- 学习VS生活
- ASP.NET MVC 表单的几种提交方式
- 让 BAT 的 Offer 不再难拿
- iOS中block实现的探究
- virtual box Failed to load unit ";";pgm"; 的error
- java学习(四) excel读取
- 全景智慧城市——NOW!!!VRSHOPPING颠覆你的购物认知!
- 201521123026 《java程序设计》 第九周学习总结
- LVS集群之工作原理和调度算法(2)
- 由会话信息保存认识ThreadLocal
- APP测试要点—UI、功能测试
- TTL 和 DNS TTL 的区别
- JS实现定时任务,每隔N秒请求后台——setInterval定时和ajax请求
热门文章
- 实现MongoDB读写分离的“读偏好”介绍
- The account that is running SQL Server Setup does not have one or all of the following rights: the right to back up files and directories, the right to manage auditing and the security log and the rig
- 20181218 - PostgreSQL Auto Commit Guide(自动提交)
- Python 序列化模块(json,pickle,shelve)
- 【原】Java学习笔记022 - 字符串
- local_irq_disable和disable_irq的区别
- centos后台运行Python
- 调用远程主机上的 RMI 服务时抛出 java.rmi.ConnectException: Connection refused to host: 127.0.0.1 异常原因及解决方案
- springMVC DispatcherServlet类关系图
- Python编码规范(PEP8)及奇技淫巧(不断更新)