#include<cstdio>//wrong_codes #include<algorithm> using namespace std; ],anss; ],T,TT,n,endd; int main() { int i,j; scanf("%d",&T); ;TT<=T;TT++) { scanf("%d",&n); ;i<=n;i++) scanf("%d",&a[i]); ;i…
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…
一排1到n的格子,每个格子上有黄金 ai ,你最开始在 1 号,每一次投骰子决定到哪一个格子,超出1~n范围则重新投掷,你到了哪个格子就得到哪个格子的金币,问最终在n 能得到金币的期望. 思路:做题经验,期望都是从后推到前,我们从最大开始dp, 1~6  种情况的传递,但是当前面的格子数少于6的时候需要特判: #include<cstdio> #include<algorithm> #include<math.h> #include<string.h> #i…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1030 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> using namespace std; ; const int INF = 0x3f3f3f3f; double dp[maxn]; int a[maxn]; int main() { //f…
题目链接: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…
题目链接: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…
D - Discovering Gold Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1030 Description You are in a cave, a long cave! The cave can be represented by a 1…
表示对概率和期望还不是很清楚定义. 目前暂时只知道概率正推,期望逆推,然后概率*某个数值=期望. 为什么期望是逆推的,例如你求到某一个点的概率我们可以求得,然后我们只要运用dp从1~n每次都加下去就好了,这样求出来的就是最后的概率.那么期望呢,就是这个概率*数值就行了.但是有时候这么绕来绕去太麻烦了,我们干脆就逆过来.然后我们发现,根据期望的定义,逆过来以后反正做结果并没有太大的改变,dp从n~1就可以了,并且每次都加上数值,然后在for的途中,这个数值是会不断的乘以概率的,所以期望适合用逆推的…