HDOJ 5001 Walk】的更多相关文章

概率DP dp[j][d] 表示不经过i点走d步到j的概率, dp[j][d]=sigma ( dp[k][d-1] * Probability ) ans = sigma ( dp[j][D] ) Walk Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 401    Accepted Submission(s): 261 Spe…
题目传送门 /* 题意:求从(1, 1)走到(n, m)的二进制路径值最小 BFS+贪心:按照标程的作法,首先BFS搜索所有相邻0的位置,直到1出现.接下去从最靠近终点的1开始, 每一次走一步,不走回头路,只往下或往右走.因为满足i = j + (i - j)的坐标(j, i - j)可能不止一个,选择最小的访问 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath…
题目传送门 /* 题意:问一个点到另一个点的最少转向次数. 坐标离散化+BFS:因为数据很大,先对坐标离散化后,三维(有方向的)BFS 关键理解坐标离散化,BFS部分可参考HDOJ_1728 */ #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <vector> #include <map> #include <…
Walk Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5001 Description I used to think I could be anything, but now I know that I couldn't do anything. So I started traveling. The nation looks like a connected bid…
Walk I used to think I could be anything, but now I know that I couldn't do anything. So I started traveling. The nation looks like a connected bidirectional graph, and I am randomly walking on it. It means when I am at node i, I will travel to an ad…
Walk Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 266    Accepted Submission(s): 183 Special Judge Problem Description I used to think I could be anything, but now I know that I couldn't d…
解题思路:这是一道简单的概率dp,只要处理好相关的细节就可以了. dp[d][i]表示走d步时走到i的改概率,具体参考代码: #include<cstdio> #include<cstring> #include<algorithm> #include<vector> #include<cstring> using namespace std; ; ; double dp[N][M]; int n, m, t, d; vector<int&…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5335 #include<stdio.h> #include<cstring> #include<cmath> #include<algorithm> using namespace std; ; char R[MAXN][MAXN]; bool used[MAXN][MAXN]; ], yy[]; ] = { , , , -}; ] = { , -, , };…
1. 题目描述一个人沿着一条长度为n个链行走,给出了每秒钟由i到j的概率($i,j \in [1,n]$).求从1开始走到n个时间的期望. 2. 基本思路显然是个DP.公式推导也相当容易.不妨设$dp[i], i \in [1,n]$表示由i到n的期望时间.\begin{align}    dp[i] &= \Sigma_{j=1}^{n} p(i, j) (dp[j] + 1),    &j<n\\    dp[i] &= 0 &i=n\end{align}显然这是…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 56784    Accepted Submission(s): 19009 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…