首页 > 代码库 > Codeforces 235B Let's Play Osu! 概率dp(水
Codeforces 235B Let's Play Osu! 概率dp(水
题目链接:点击打开链接
给定n表示有n个格子
下面每个格子为O的概率是多少。
对于一段连续 x 个O的价值就是 x*x ;
问:
获得的价值的期望是多少。
思路:
把公式拆一下。。
#include <cstdio> const int N = 100005; double dp[N][2], p[N]; int main(){ int n; scanf("%d", &n); for(int i = 1; i <= n; i ++) { scanf("%lf", &p[i]); } dp[0][0] = dp[0][1] = 0; double ans = 0; for(int i = 1; i <= n; i ++) { dp[i][0] = dp[i-1][0] * p[i] + p[i]; dp[i][1] = dp[i-1][1] + 2 * dp[i][0] - p[i]; } printf("%.10f\n", dp[n][1]); return 0; }
Codeforces 235B Let's Play Osu! 概率dp(水
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。