hdu-4405-Aeroplane chess-概率DP
来源:互联网 发布:icp算法源码 编辑:程序博客网 时间:2024/06/02 15:13
还是那么做。。。
无非加了一条跳转。。。几乎都差不多。。
#include <iostream>#include<stdio.h>#include<string.h>#include<math.h>using namespace std;#define maxn 110000#define eps 1e-6#define zero(x) (fabs(x)<0?0:x)double dp[maxn];int pre[maxn];int n;double dos(int x){ if(x>=n)return 0; if(dp[x]>-0.5)return dp[x]; if(pre[x]!=0) { dp[x]=dos(pre[x]); return dp[x]; } dp[x]=0; for(int i=1;i<=6;i++) { dp[x]+=(1.0/6)*(dos(x+i)+1); } return dp[x];}int main(){ int m,x,y; while(~scanf("%d%d",&n,&m)&&(n||m)) { memset(dp,-1,sizeof(dp)); memset(pre,0,sizeof(pre)); for(int i=1;i<=m;i++) { scanf("%d%d",&x,&y); pre[x]=y; } printf("%.4f\n",dos(0)); } return 0;}
0 0
- hdu 4405 Aeroplane chess 概率dp
- hdu 4405 Aeroplane chess(概率dp)
- HDU 4405 Aeroplane chess (概率dp)
- hdu 4405 Aeroplane chess (概率dp)
- hdu 4405 Aeroplane chess(概率dp)
- HDU 4405 Aeroplane chess (概率dp)
- HDU 4405 Aeroplane chess(概率dp)
- hdu-4405-Aeroplane chess-概率DP
- hdu 4405 Aeroplane chess(概率dp)
- hdu 4405 Aeroplane chess 概率dp
- hdu 4405 Aeroplane chess (概率DP)
- hdu 4405 Aeroplane chess (概率dp)
- HDU 4405 Aeroplane chess 概率dp
- HDU - 4405 Aeroplane chess(概率dp)
- HDU 4405 Aeroplane chess (概率DP)
- HDU 4405 Aeroplane chess 概率DP
- hdu 4405 Aeroplane chess(概率dp)
- HDU 4405 Aeroplane chess(概率DP)
- 现在公开一个DHT网络爬虫网络爬虫供大家一起交流
- STL了解(初级)
- 2014甘肃高考志愿填报时间表
- 使用freebsd-update升级FreeBSD8.2到FreeBSD8.4(ezjails主机)
- JavaScript-RegExp对象只能使用一次问题解决方法
- hdu-4405-Aeroplane chess-概率DP
- web dao查到数据库然后显示页面
- android xml解析
- [转]Golang适合高并发场景的原因分析
- 程序员必须知道的10大基础实用算法及其讲解
- C++ 习题 输出日期时间--友元函数
- prime number test in Ruby
- pydev-python 链接mysql数据库(mac系统)
- iOS APNS远程推送(最详细解析)