HDU-4405-Aeroplane chess
来源:互联网 发布:淘宝信用卡在哪申请 编辑:程序博客网 时间:2024/06/16 03:45
ACM模版
描述
题解
概率
状态转移方程很容易想,设
状态转移方程如下:
但是题目中提到了传送门,也就是说当到达
剩下的就没有什么问题了,具体看代码吧!
代码
#include <cstdio>#include <algorithm>#include <cstring>#define ll long longconst int MAXN = 1e5 + 10;int n, m;int vis[MAXN];double dp[MAXN];int main(){ while (~scanf("%d%d", &n, &m) && n + m) { memset(dp, 0, sizeof(dp)); memset(vis, -1, sizeof(vis)); int a, b; for (int i = 1; i <= m; i++) { scanf("%d%d", &a, &b); vis[a] = b; } for (int i = n - 1; i >= 0; i--) { if (vis[i] == -1) { for (int j = 1; j <= 6; j++) { dp[i] += dp[i + j] / 6.0; } dp[i] += 1; } else { dp[i] = dp[vis[i]]; } } printf("%.4lf\n", dp[0]); } return 0;}
阅读全文
0 0
- hdu 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- HDU 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- HDU 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- HDU 4405 Aeroplane chess
- HDU 4405 Aeroplane chess
- HDU 4405Aeroplane chess
- HDU 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- hdu #4405:Aeroplane chess
- HDU 4405 Aeroplane chess
- HDU 4405 Aeroplane chess
- HDU 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- smb.conf 配置
- 利用ccache加快android源码和linux内核编译速度的方法
- Spring的自定义注解
- HashMap 理解记录
- Java继承
- HDU-4405-Aeroplane chess
- J2EE开发的颠覆者SpringBoot快速入门!
- oracle数据库(范式)
- Win32实现DES加密算法
- 第九周项目2-二叉树递归遍历
- Java数据结构与算法解析(八)——伸展树
- 爬取广州链家租房信息,并用tableau进行数据分析
- meanshift算法学习(一):opencv中的calcBackProject
- hive 优化 控制 map 和 reduce的数量