HDU4405-Aeroplane chess(概率DP求期望)】的更多相关文章

Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz starts at grid 0. For each step he throws a dice(a dice have six faces with equal probability to face up and the numbers on the faces are 1,2,3,4,5,6). Whe…
http://acm.hdu.edu.cn/showproblem.php?pid=4405 题意:在一个1×n的格子上掷色子,从0点出发,掷了多少前进几步,同时有些格点直接相连,即若a,b相连,当落到a点时直接飞向b点.求走到n或超出n期望掷色子次数 分析:简单的题目,拿来入门很不错: 如果没有飞机的线 ,这题就是直接 dp[i]+=dp[i+x]/6 +1 了 : 当前的期望由子期望相加 : 那航线怎么考虑呢?一开始我以为是加上可以走到点的dp[v] ,可是仔细推敲这是不对了,在注意到航线的…
题意:某人掷骰子,数轴上前进相应的步数,会有瞬移的情况,求从0到N所需要的期望投掷次数. 解题关键:期望dp的套路解法,一个状态可以转化为6个状态,则该状态的期望,可以由6个状态转化而来.再加上两个状态的消耗即可. #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #include<cmath> #include<iostream> usi…
LOOPS Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others) Total Submission(s): 1864    Accepted Submission(s): 732 Problem Description Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help h…
Collecting Bugs Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stuff, he collects software bugs. When Ivan gets a new program, he classifies all possible bugs into n categories. Each day he discovers…
Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1667    Accepted Submission(s): 1123 Problem Description Hzz loves aeroplane chess very much. The chess map contains N+1 grids lab…
Aeroplane chess Problem Description Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz starts at grid 0. For each step he throws a dice(a dice have six faces with equal probability to face up and the number…
题意:你从0开始,要跳到 n 这个位置,如果当前位置是一个飞行点,那么可以跳过去,要不然就只能掷骰子,问你要掷的次数数学期望,到达或者超过n. 析:概率DP,dp[i] 表示从 i  这个位置到达 n 要掷的次数的数学期望.然后每次掷的数就是1-6,概率都相等为1/6,再特殊标记一下飞行点,那么就容易写过了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #in…
借鉴自:https://www.cnblogs.com/keyboarder-zsq/p/6216762.html 题意:n个格子,每个格子有一个值.从1开始,每次扔6个面的骰子,扔出几点就往前几步,然后把那个格子的金子拿走: 如果扔出的骰子+所在位置>n,就重新扔,直到在n: 问取走这些值的期望值是多少 解析: [1] [2] [3][4] [5] [6] [7] [8] [9] //格子和值都是一样,所以下述的话,值就是格子,格子就是值... 比如这样的9个格子,我们总底往上来 对于第9个格…
题目大意:一个跳棋游戏,每置一次骰子前进相应的步数.但是有的点可以不用置骰子直接前进,求置骰子次数的平均值. 题目分析:状态很容易定义:dp(i)表示在第 i 个点出发需要置骰子的次数平均值.则状态转移方程为: dp(i)=singma(pk*dp(i+k))+1 (如果在 i 处必须置骰子才能前进) dp(i)=dp(s) (如果在 i 处能直接到达s处) 代码如下: # include<iostream> # include<cstdio> # include<vecto…