hdu4405 概率期望
来源:互联网 发布:caffe softmax layer 编辑:程序博客网 时间:2024/05/16 23:54
http://acm.hdu.edu.cn/showproblem.php?pid=4405
hdu4405写出期望递推公式即可:
t[ now ]表示从now到n 投掷次数期望
now: n - 1 -> 0; j: 1 -> 6
t[ now ] += ( (t[ now + j ]) + 1 / 6.0)
如果有xi -> yi的捷径
t[ x ] = t[ y ] (x < y)即可
#include <iostream>#include <string>#include <algorithm>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;const int MAXN = 1e5 + 10;int trans[MAXN];double dp[MAXN], p[7];void solve(){int n, m, x, y;while(scanf("%d%d", &n, &m) == 2 && (n || m)){memset(trans, 0, sizeof(int) * (n + 1));memset(dp, 0, sizeof(dp));for(int i = 0; i < m; ++i){scanf("%d%d", &x, &y);trans[x] = y;}for(int i = n - 1; i >= 0; --i){if(trans[i])dp[i] += (dp[ trans[i] ] );elsefor(register int j = i + 1; j <= i + 6; ++j)dp[i] += ((1.0 + dp[j]) / 6.0);}printf("%.4lf\n", dp[0]);}}int main(){solve();return 0;}
0 0
- hdu4405 概率期望
- HDU4405(概率DP求期望)
- hdu4405(概率DP求期望)
- hdu4405--Aeroplane chess+概率期望dp
- HDU4405 Aeroplane chess (概率DP求期望)
- hdu4405 Aeroplane chess【概率DP+期望问题】
- HDU4405:Aeroplane chess(概率dp & 期望)
- HDU4405-Aeroplane chess(概率DP求期望)
- hdu4405[Aeroplane chess] 有点懂了期望概率DP
- hdu4405 Aeroplane chess 期望
- hdu4405(期望dp)
- hdu4405(概率DP)
- HDU4405概率DP入门
- hdu4405概率dp入门
- hdu4405 概率dp
- hdu4405概率DP
- hdu4405(概率dp)
- hdu4405(概率dp)
- 浅谈对工程管理器——make的理解
- 微信学习_01_开发环境搭建
- 【杭电oj】3466 - Proud Merchants(01背包,排序处理)
- 编写一个程序,自定义以为数组,删除一维数组中所有相同的数,使之只剩一个。数组中的数按由小到大顺序排列,并显示运行所用时间。
- LeetCode - 33. Search in Rotated Sorted Array
- hdu4405 概率期望
- linux:定时任务出现command not found
- uva10300 Ecological Premium
- 小米 懂二进制
- Android从启动到程序运行发生的事情
- WIFI网卡驱动移植
- 源代码管理的基本操作
- CNNs学习笔记(6):涉及问题总结
- css在线参考手册