LightOJ1030 Discovering Gold(概率DP)】的更多相关文章

题目链接:https://cn.vjudge.net/problem/LightOJ-1030 You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold. Initially you are in position 1. Now each turn you throw a perfect 6 si…
You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold. Initially you are in position 1. Now each turn you throw a perfect 6 sided dice. If you get X in the dice after throwin…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1030 题目大意:有一个很长的洞穴, 可以看做是1-n的格子.你的起始位置在1的地方, 每个格子中都有价值为v[i]的宝藏. 有一个6面的骰子,数字为从1-6, 每次摇一次骰子, 得到的数字x后, 你可以到达距离当前位置大x的位置, 并且得到那个位置的宝藏. 如果要走的位置在n的外面, 那么在此摇骰子, 直到找到一个合适的数字.到达n位置的时候结束. 现在想知道走到n位置的能够…
题目链接:LightOJ - 1030 Description You are in a cave, a long cave! The cave can be represented by a \(1 \times N\) grid. Each cell of the cave can contain any amount of gold. Initially you are in position \(1\). Now each turn you throw a perfect \(6\) s…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1030 题意:在一个1*n 的格子里,每个格子都有相应的金币数,走到相应格子的话,就会得到该格子的金币.  现在有一个人在1这个位置,手里有一颗骰子,骰子摇到几,他就前进几步,但如果当前位置+骰子数 > n,那么他就会重新摇色子一直到<=n为止. 走到n这个位置的话,意味着游戏结束了. 问游戏结束时,这个人得到金币的期望. 设dp[i]表示从i号格子出去的期望,所以dp[i]是和i后…
题目大概说一个1×n的格子,每个格子都有一定的黄金,起点在1,终点在n,通过投掷6面骰子前进与骰子点数一样的步数,如果会超过n就重新投,每到一个格子就获得其中的黄金.问到达n能得到的黄金数目的期望. 求概率是正推,求期望是逆推..容我慢慢体会.. 期望: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ]; int main(){ ]; scanf("%d&…
题目链接:https://vjudge.net/problem/LightOJ-1030 知识点: 概率与期望 解题思路: 设某一个点 \(i\) 能到达的点的个数为 \(x\),其上有金 \(g\),则该点上的期望 \(f(i) = g + \frac{f(i+1) + f(i+2) + ... + f(i+x)}{x}\). AC代码: #include <bits/stdc++.h> using namespace std; +; double dp[maxn]; int main(){…
题目链接:https://vjudge.net/problem/LightOJ-1030 1030 - Discovering Gold    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can…
B - Discovering Gold Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold. Initially y…
1030 - Discovering Gold    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold. Initially you are…