hdu4405 Aeroplane chess 【期望dp】
来源:互联网 发布:淘宝卖家在哪充值金币 编辑:程序博客网 时间:2024/05/24 06:18
解题思路:
貌似题意是有捷径就走捷径。
那就是裸的期望dp了。
设dp[i]为当前所处位置到目标状态的期望,则当
转移方程为:
有捷径:
没有捷径:
最后dp[0]即为答案。
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>#include<cmath>#include<vector>#include<queue>#define ll long longusing namespace std;int getint(){ int i=0,f=1;char c; for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar()); if(c=='-')f=-1,c=getchar(); for(;c>='0'&&c<='9';c=getchar())i=(i<<3)+(i<<1)+c-'0'; return i*f;}const int N=100005;int n,m,to[N];double dp[N];int main(){ //freopen("lx.in","r",stdin); int x,y; while(n=getint()) { memset(dp,0,sizeof(dp)); memset(to,0,sizeof(to)); if(!n)break; m=getint(); while(m--) { x=getint(),y=getint(); to[x]=y; } for(int i=n-1;i>=0;i--) { if(to[i])dp[i]=dp[to[i]]; else { for(int j=1;j<=6;j++) dp[i]+=dp[i+j]; dp[i]=dp[i]*1.0/6+1; } } printf("%.4lf\n",dp[0]); } return 0;}
阅读全文
0 0
- hdu4405 Aeroplane chess 【期望dp】
- 【期望DP】HDU4405 Aeroplane chess
- hdu4405--Aeroplane chess+概率期望dp
- hdu4405 Aeroplane chess(期望dp)
- HDU4405 Aeroplane chess (概率DP求期望)
- hdu4405 Aeroplane chess【概率DP+期望问题】
- HDU4405:Aeroplane chess(概率dp & 期望)
- hdu4405 Aeroplane chess 期望
- HDU4405-Aeroplane chess(概率DP求期望)
- hdu4405[Aeroplane chess] 有点懂了期望概率DP
- hdu4405 Aeroplane chess (概率dp)
- HDU4405--Aeroplane chess--概率DP
- 【HDU4405】【Aeroplane chess】【概率dp】
- hdu4405 Aeroplane chess---金华网络赛 期望
- LightOJ 1030 Discovering Gold + Hdu4405 Aeroplane chess (期望)
- HDU4405 Aeroplane chess
- hdu4405 Aeroplane chess
- HDU4405 Aeroplane chess
- 常见配置redis.conf介绍
- Qt中文文档-QAbstractAnimation
- 替换实现逐帧动画,解决内存问题
- KITTI数据集格式说明
- vue中v-if与v-for的区别
- hdu4405 Aeroplane chess 【期望dp】
- LeetCode基础
- 关于MySQL中的约束
- MongoDB学习笔记(五) MongoDB文件存取操作
- 实战解析—论三年内快速成长为一名技术专家
- 软件架构模式-第二章事件驱动架构(上)
- 软件架构模式-第一章分层架构(下)
- 实战Spring事务传播性与隔离性
- 《平白语录》平白烽火戏码农